vertigo_vhdl 0.8.10 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beaea4415336c64910ab051d6882dbc9e5320f65a9531a2862a336f30142d7ff
4
- data.tar.gz: f190bce2287c4d40b69a191e5c34ae6bfaee628f3c19213ddec253d8c4fb6a0f
3
+ metadata.gz: a3459a1e9abbe835d383e2137cfa7f34146d14d54813888019e75d72ac37a24d
4
+ data.tar.gz: 9a02b22f74a9843113918dfcb26e7f97681c72244df7bdcaa4651549294dec16
5
5
  SHA512:
6
- metadata.gz: e35cadb37ba4f987501b079bc9c69f73bbb3d1699ec1966410448e4dd4637b26f5d3aa205121cf1fbebcf94c6ccf4de21dd21e121a3291793d6c264bfb980b32
7
- data.tar.gz: 6bdd446db85780a7bd16214776651fed9896d6cfd5edf5e4a4fae483bb0b2d8323cf6d890722f346586f0e2ceabf0bbeefda219d46cfa65bc64cfd9fdebc76e9
6
+ metadata.gz: e676079468bfc02a31d541aef60289f2da02a7daf90c59019e240e3eb5b833ed1ff94f4391398bc61fecae80ff62a255c5db1a809b12f4dae37f3ae019a507aa
7
+ data.tar.gz: 2297f5a293fb186a4b4c7073b32d3a70af9df714835b8e58a1686c1757552629c0c6ec536ab0f18761d3d664b504b11952f325af89157392959f9ffd47978d48
@@ -1259,6 +1259,7 @@ module Vertigo
1259
1259
 
1260
1260
 
1261
1261
  def parse_term
1262
+ #pp showNext
1262
1263
  if showNext.is_a? [:ident,:dot,:integer,:natural,:positive,:decimal_literal,:based_literal,:char_literal,:string_literal,:true,:false,:bit_string_literal,:lparen,:others,:abs,:not,:sub,:open]
1263
1264
  case showNext.kind
1264
1265
  when :ident
@@ -13,15 +13,19 @@ module Vertigo
13
13
  end
14
14
 
15
15
  def generate_from ast
16
- @ast=ast
17
- entity_arch=find_entity_arch()
18
- detecting_clk_and_reset(entity_arch)
19
- vhdl_tb=gen_code()
20
- @tb_name=@entity_name+"_tb"
21
- tb_filename=@tb_name+".vhd"
22
- File.open(tb_filename,'w'){|f| f.puts vhdl_tb}
23
- puts "=> generated testbench : #{tb_filename}" unless options[:mute]
24
- return tb_filename
16
+ begin
17
+ @ast=ast
18
+ entity_arch=find_entity_arch()
19
+ detecting_clk_and_reset(entity_arch)
20
+ vhdl_tb=gen_code()
21
+ @tb_name=@entity_name+"_tb"
22
+ tb_filename=@tb_name+".vhd"
23
+ File.open(tb_filename,'w'){|f| f.puts vhdl_tb}
24
+ puts "=> generated testbench : #{tb_filename}" unless options[:mute]
25
+ return tb_filename
26
+ rescue Exception => e
27
+ puts e.backtrace
28
+ end
25
29
  end
26
30
 
27
31
  def line n=80
@@ -70,7 +74,9 @@ module Vertigo
70
74
  code << " s <=not(s);"
71
75
  code << "end procedure;"
72
76
  code.newline
73
- @entity.ports.each do |port|
77
+ # bug discovered by a student : when he forgets "in" or "out" in entity port...
78
+ # fix : compact
79
+ @entity.ports.compact.each do |port|
74
80
  port_name=port.name.str.ljust(@max_length_str)
75
81
  port_type=port.type.str
76
82
  code << "signal #{port_name} : #{port_type};" unless @excluded.include?(port)
@@ -113,12 +119,14 @@ module Vertigo
113
119
  code << line
114
120
  code << comment("Design Under Test")
115
121
  code << line
116
- code << "dut : entity work.#{@entity_name}(#{@arch_name})"
122
+ str="dut : entity work.#{@entity_name}"
123
+ str+="(#{@arch_name})" if @arch_name
124
+ code << str
117
125
  code.indent=2
118
126
  code << "port map ("
119
127
  code.indent=4
120
128
 
121
- @entity.ports.each_with_index do |port,idx|
129
+ @entity.ports.compact.each_with_index do |port,idx|
122
130
  port_name=port.name.str.ljust(@max_length_str)
123
131
  port_type=port.type.str
124
132
  if idx < @entity.ports.size-1
@@ -164,13 +172,13 @@ module Vertigo
164
172
  puts "=> found entity '#{entity.name.str}'" unless options[:mute]
165
173
  @arch=ast.design_units.find{|du| du.is_a? Architecture}
166
174
  if @arch.nil?
167
- puts msg="ERROR : no architecture found"
168
- raise msg
175
+ puts msg="WARNING : no architecture found"
176
+ else
177
+ puts "=> found architecture '#{arch.name.str}'" unless options[:mute]
169
178
  end
170
179
 
171
- puts "=> found architecture '#{arch.name.str}'" unless options[:mute]
172
180
  @entity_name=@entity.name.str
173
- @arch_name=@arch.name.str
181
+ @arch_name=@arch.name.str if @arch
174
182
  [@entity,@arch]
175
183
  end
176
184
 
@@ -182,7 +190,20 @@ module Vertigo
182
190
  @rst = inputs.sort_by{|input| levenshtein_distance(input.name.str,"reset_n")}.first
183
191
  puts "\t-most probable clk : #{@clk.name.str}" unless options[:mute]
184
192
  puts "\t-most probable reset : #{@rst.name.str}" unless options[:mute]
185
- @max_length_str=entity.ports.map{|port| port.name.str.size}.max
193
+
194
+ # bug discovered by a student : when he forgets "in" or "out" in port !
195
+ # fix : .compact
196
+ @max_length_str=entity.ports.compact.map{|port| port.name.str.size}.max
197
+
198
+ print "\t-validate [Y/n] ? "
199
+ answer=$stdin.gets.chomp
200
+ if answer=="n"
201
+ puts "ok, switching to 'clk' and 'reset_n'"
202
+ @reset_name="reset_n"
203
+ @clk_name="clk"
204
+ @excluded=[]
205
+ return
206
+ end
186
207
  @excluded=[@clk,@rst]
187
208
  @reset_name=@rst.name.str
188
209
  @clk_name=@clk.name.str
@@ -1,3 +1,3 @@
1
1
  module Vertigo
2
- VERSION="0.8.10"
2
+ VERSION="0.8.12"
3
3
  end
@@ -0,0 +1,79 @@
1
+ library ieee;
2
+ use ieee.std_logic_1164.all;
3
+ use ieee.numeric_std.all;
4
+
5
+ entity arbitre is
6
+ port(
7
+ clk : in std_logic;
8
+ reset_n : in std_logic;
9
+ r : std_logic_vector(1 downto 0);
10
+ outputs : out std_logic_vector(1 downto 0)
11
+ );
12
+ end arbitre;
13
+
14
+ architecture arch of arbitre is
15
+ type etat is (A, B, C, D);
16
+ signal state, next_state : etat;
17
+ begin
18
+ p0 : process(clk, reset_n)
19
+ begin
20
+ if reset_n = '0' then
21
+ state <= A;
22
+ elsif rising_edge(clk) then
23
+ state <= next_state;
24
+ end if;
25
+ end process;
26
+
27
+ p1 : process(reset_n, r)
28
+ begin
29
+ next_state <= state;
30
+ case state is
31
+ when A =>
32
+ if r = "10" or r = "11" then
33
+ state <= C;
34
+ elsif r = "01" then
35
+ state <= D;
36
+ elsif r = "00" then
37
+ state <= state;
38
+ end if;
39
+ when B =>
40
+ if r = "01" or r = "11" then
41
+ state <= D;
42
+ elsif r = "10" then
43
+ state <= C;
44
+ elsif r = "00" then
45
+ state <= state;
46
+ end if;
47
+ when C =>
48
+ if r = "01" then
49
+ state <= D;
50
+ elsif r = "00" then
51
+ state <= B;
52
+ elsif r = "10" or r = "11" then
53
+ state <= state;
54
+ end if;
55
+ when D =>
56
+ if r = "10" then
57
+ state <= C;
58
+ elsif r = "00" then
59
+ state <= A;
60
+ elsif r = "01" or r = "11" then
61
+ state <= state;
62
+ end if;
63
+ end case;
64
+ end process;
65
+
66
+ p3 : process(state)
67
+ begin
68
+ if state = A then
69
+ outputs <= "00";
70
+ elsif state = B then
71
+ outputs <= "00";
72
+ elsif state = C then
73
+ outputs <= "10";
74
+ elsif state = D then
75
+ outputs <= "01";
76
+ end if;
77
+ end process;
78
+ end arch;
79
+
@@ -0,0 +1,67 @@
1
+ --------------------------------------------------------------------------------
2
+ -- this file was generated automatically by Vertigo Ruby utility
3
+ -- date : (d/m/y h:m) 15/02/2023 14:26
4
+ -- author : Jean-Christophe Le Lann - 2014
5
+ --------------------------------------------------------------------------------
6
+
7
+ library ieee;
8
+ use ieee.std_logic_1164.all;
9
+ use ieee.numeric_std.all;
10
+
11
+ entity arbitre_tb is
12
+ end entity;
13
+
14
+ architecture bhv of arbitre_tb is
15
+ constant HALF_PERIOD : time :=5 ns;
16
+
17
+ signal clk : std_logic := '0';
18
+ signal reset_n : std_logic := '0';
19
+
20
+ signal running : boolean := true;
21
+
22
+ procedure wait_cycles(n : natural) is
23
+ begin
24
+ for i in 0 to n-1 loop
25
+ wait until rising_edge(clk);
26
+ end loop;
27
+ end procedure;
28
+
29
+ procedure toggle(signal s : inout std_logic) is
30
+ begin
31
+ wait until rising_edge(clk);
32
+ s <=not(s);
33
+ wait until rising_edge(clk);
34
+ s <=not(s);
35
+ end procedure;
36
+
37
+ signal outputs : std_logic_vector(1 downto 0);
38
+ begin
39
+ --------------------------------------------------------------------------------
40
+ -- clock and reset
41
+ --------------------------------------------------------------------------------
42
+ reset_n <= '0','1' after 123 ns;
43
+
44
+ clk <= not(clk) after HALF_PERIOD when running else clk;
45
+ --------------------------------------------------------------------------------
46
+ -- Design Under Test
47
+ --------------------------------------------------------------------------------
48
+ dut : entity work.arbitre(arch)
49
+ port map (
50
+ clk => clk ,
51
+ reset_n => reset_n,
52
+ outputs => outputs);
53
+ --------------------------------------------------------------------------------
54
+ -- sequential stimuli
55
+ --------------------------------------------------------------------------------
56
+ stim : process
57
+ begin
58
+ report "running testbench for arbitre(arch)";
59
+ report "waiting for asynchronous reset";
60
+ wait until reset_n='1';
61
+ wait_cycles(10);
62
+ wait_cycles(200);
63
+ report "end of simulation";
64
+ running <= false;
65
+ wait;
66
+ end process;
67
+ end bhv;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vertigo_vhdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.10
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Christophe Le Lann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-07 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby handwritten VHDL parser and utilities
14
14
  email: jean-christophe.le_lann@ensta-bretagne.fr
@@ -35,6 +35,8 @@ files:
35
35
  - lib/vertigo/version.rb
36
36
  - lib/vertigo/vertigo.rkg
37
37
  - lib/vertigo/visitor_vertigo_rkgen.rb
38
+ - tests/ghdl_tests/arbitre.vhd
39
+ - tests/ghdl_tests/arbitre_tb.vhd
38
40
  - tests/ghdl_tests/fsm.vhd
39
41
  - tests/ghdl_tests/fsm_synth.vhd
40
42
  - tests/parser_tests/test_MUST_fail.vhd