vertigo_vhdl 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/bin/vertigo +7 -0
  3. data/lib/vertigo.rb +4 -0
  4. data/lib/vertigo/ast.rb +87 -0
  5. data/lib/vertigo/ast_vertigo_rkgen.rb +607 -0
  6. data/lib/vertigo/code.rb +57 -0
  7. data/lib/vertigo/compiler.rb +61 -0
  8. data/lib/vertigo/generic_lexer.rb +61 -0
  9. data/lib/vertigo/generic_parser.rb +44 -0
  10. data/lib/vertigo/indent.rb +20 -0
  11. data/lib/vertigo/lexer.rb +172 -0
  12. data/lib/vertigo/parser.rb +1458 -0
  13. data/lib/vertigo/pretty_printer.rb +749 -0
  14. data/lib/vertigo/runner.rb +115 -0
  15. data/lib/vertigo/tb_generator.rb +81 -0
  16. data/lib/vertigo/template.tb.vhd +72 -0
  17. data/lib/vertigo/token.rb +67 -0
  18. data/lib/vertigo/version.rb +3 -0
  19. data/lib/vertigo/vertigo.rkg +354 -0
  20. data/lib/vertigo/visitor_vertigo_rkgen.rb +447 -0
  21. data/tests/ghdl_tests/fsm.vhd +98 -0
  22. data/tests/ghdl_tests/fsm_synth.vhd +248 -0
  23. data/tests/ghdl_tests/test_fsm.vhd +162 -0
  24. data/tests/parser_tests/else.vhd +64 -0
  25. data/tests/parser_tests/test_MUST_fail.vhd +1 -0
  26. data/tests/parser_tests/test_accelerator.vhd +160 -0
  27. data/tests/parser_tests/test_accelerator_pp.vhd +144 -0
  28. data/tests/parser_tests/test_aggregate.vhd +17 -0
  29. data/tests/parser_tests/test_aggregate_pp.vhd +15 -0
  30. data/tests/parser_tests/test_archi_1.vhd +45 -0
  31. data/tests/parser_tests/test_archi_1_pp.vhd +41 -0
  32. data/tests/parser_tests/test_array_array_00.vhd +25 -0
  33. data/tests/parser_tests/test_array_array_00_pp.vhd +25 -0
  34. data/tests/parser_tests/test_array_urange.vhd +25 -0
  35. data/tests/parser_tests/test_array_urange_pp.vhd +25 -0
  36. data/tests/parser_tests/test_chu-1.vhd +80 -0
  37. data/tests/parser_tests/test_chu-1_pp.vhd +104 -0
  38. data/tests/parser_tests/test_concat.vhd +11 -0
  39. data/tests/parser_tests/test_concat_pp.vhd +14 -0
  40. data/tests/parser_tests/test_counter.vhd +35 -0
  41. data/tests/parser_tests/test_counter_pp.vhd +35 -0
  42. data/tests/parser_tests/test_de2.vhd +358 -0
  43. data/tests/parser_tests/test_de2_pp.vhd +274 -0
  44. data/tests/parser_tests/test_encode.vhd +2679 -0
  45. data/tests/parser_tests/test_encode_pp.vhd +2549 -0
  46. data/tests/parser_tests/test_fsm.vhd +162 -0
  47. data/tests/parser_tests/test_fsm_pp.vhd +125 -0
  48. data/tests/parser_tests/test_fsm_synth.vhd +248 -0
  49. data/tests/parser_tests/test_fsm_synth_pp.vhd +197 -0
  50. data/tests/parser_tests/test_function-01.vhd +33 -0
  51. data/tests/parser_tests/test_function-01_pp.vhd +18 -0
  52. data/tests/parser_tests/test_lfsr.vhd +75 -0
  53. data/tests/parser_tests/test_lfsr_pp.vhd +44 -0
  54. data/tests/parser_tests/test_microwatt_cache_ram.vhd +1 -0
  55. data/tests/parser_tests/test_microwatt_cache_ram_pp.vhd +68 -0
  56. data/tests/parser_tests/test_microwatt_common.vhd +1 -0
  57. data/tests/parser_tests/test_microwatt_common_pp.vhd +336 -0
  58. data/tests/parser_tests/test_microwatt_control.vhd +1 -0
  59. data/tests/parser_tests/test_microwatt_control_pp.vhd +187 -0
  60. data/tests/parser_tests/test_microwatt_core.vhd +1 -0
  61. data/tests/parser_tests/test_microwatt_core_debug.vhd +1 -0
  62. data/tests/parser_tests/test_microwatt_core_debug_pp.vhd +104 -0
  63. data/tests/parser_tests/test_microwatt_core_pp.vhd +231 -0
  64. data/tests/parser_tests/test_microwatt_core_tb.vhd +1 -0
  65. data/tests/parser_tests/test_microwatt_core_tb_pp.vhd +43 -0
  66. data/tests/parser_tests/test_microwatt_countzero.vhd +1 -0
  67. data/tests/parser_tests/test_microwatt_countzero_pp.vhd +120 -0
  68. data/tests/parser_tests/test_microwatt_countzero_tb.vhd +1 -0
  69. data/tests/parser_tests/test_microwatt_countzero_tb_pp.vhd +70 -0
  70. data/tests/parser_tests/test_microwatt_cr_file.vhd +1 -0
  71. data/tests/parser_tests/test_microwatt_cr_file_pp.vhd +74 -0
  72. data/tests/parser_tests/test_microwatt_cr_hazard.vhd +1 -0
  73. data/tests/parser_tests/test_microwatt_cr_hazard_pp.vhd +51 -0
  74. data/tests/parser_tests/test_microwatt_crhelpers.vhd +1 -0
  75. data/tests/parser_tests/test_microwatt_crhelpers_pp.vhd +48 -0
  76. data/tests/parser_tests/test_microwatt_dcache.vhd +1 -0
  77. data/tests/parser_tests/test_microwatt_dcache_pp.vhd +481 -0
  78. data/tests/parser_tests/test_microwatt_dcache_tb.vhd +1 -0
  79. data/tests/parser_tests/test_microwatt_dcache_tb_pp.vhd +98 -0
  80. data/tests/parser_tests/test_microwatt_decode1.vhd +1 -0
  81. data/tests/parser_tests/test_microwatt_decode1_pp.vhd +138 -0
  82. data/tests/parser_tests/test_microwatt_decode2.vhd +1 -0
  83. data/tests/parser_tests/test_microwatt_decode2_pp.vhd +300 -0
  84. data/tests/parser_tests/test_microwatt_decode_types.vhd +1 -0
  85. data/tests/parser_tests/test_microwatt_decode_types_pp.vhd +67 -0
  86. data/tests/parser_tests/test_microwatt_divider.vhd +1 -0
  87. data/tests/parser_tests/test_microwatt_divider_pp.vhd +132 -0
  88. data/tests/parser_tests/test_microwatt_divider_tb.vhd +1 -0
  89. data/tests/parser_tests/test_microwatt_divider_tb_pp.vhd +95 -0
  90. data/tests/parser_tests/test_microwatt_dmi_dtm_dummy.vhd +1 -0
  91. data/tests/parser_tests/test_microwatt_dmi_dtm_dummy_pp.vhd +29 -0
  92. data/tests/parser_tests/test_microwatt_dmi_dtm_tb.vhd +1 -0
  93. data/tests/parser_tests/test_microwatt_dmi_dtm_tb_pp.vhd +197 -0
  94. data/tests/parser_tests/test_microwatt_dmi_dtm_xilinx.vhd +1 -0
  95. data/tests/parser_tests/test_microwatt_dmi_dtm_xilinx_pp.vhd +139 -0
  96. data/tests/parser_tests/test_microwatt_execute1.vhd +1 -0
  97. data/tests/parser_tests/test_microwatt_execute1_pp.vhd +689 -0
  98. data/tests/parser_tests/test_microwatt_fetch1.vhd +1 -0
  99. data/tests/parser_tests/test_microwatt_fetch1_pp.vhd +88 -0
  100. data/tests/parser_tests/test_microwatt_fetch2.vhd +1 -0
  101. data/tests/parser_tests/test_microwatt_fetch2_pp.vhd +79 -0
  102. data/tests/parser_tests/test_microwatt_glibc_random.vhd +1 -0
  103. data/tests/parser_tests/test_microwatt_glibc_random_helpers.vhd +1 -0
  104. data/tests/parser_tests/test_microwatt_glibc_random_helpers_pp.vhd +25 -0
  105. data/tests/parser_tests/test_microwatt_glibc_random_pp.vhd +41 -0
  106. data/tests/parser_tests/test_microwatt_gpr_hazard.vhd +1 -0
  107. data/tests/parser_tests/test_microwatt_gpr_hazard_pp.vhd +68 -0
  108. data/tests/parser_tests/test_microwatt_helpers.vhd +1 -0
  109. data/tests/parser_tests/test_microwatt_helpers_pp.vhd +153 -0
  110. data/tests/parser_tests/test_microwatt_icache.vhd +1 -0
  111. data/tests/parser_tests/test_microwatt_icache_pp.vhd +337 -0
  112. data/tests/parser_tests/test_microwatt_icache_tb.vhd +1 -0
  113. data/tests/parser_tests/test_microwatt_icache_tb_pp.vhd +104 -0
  114. data/tests/parser_tests/test_microwatt_insn_helpers.vhd +1 -0
  115. data/tests/parser_tests/test_microwatt_insn_helpers_pp.vhd +208 -0
  116. data/tests/parser_tests/test_microwatt_loadstore1.vhd +1 -0
  117. data/tests/parser_tests/test_microwatt_loadstore1_pp.vhd +222 -0
  118. data/tests/parser_tests/test_microwatt_logical.vhd +1 -0
  119. data/tests/parser_tests/test_microwatt_logical_pp.vhd +87 -0
  120. data/tests/parser_tests/test_microwatt_multiply.vhd +1 -0
  121. data/tests/parser_tests/test_microwatt_multiply_pp.vhd +84 -0
  122. data/tests/parser_tests/test_microwatt_multiply_tb.vhd +1 -0
  123. data/tests/parser_tests/test_microwatt_multiply_tb_pp.vhd +75 -0
  124. data/tests/parser_tests/test_microwatt_plru.vhd +1 -0
  125. data/tests/parser_tests/test_microwatt_plru_pp.vhd +46 -0
  126. data/tests/parser_tests/test_microwatt_plru_tb.vhd +1 -0
  127. data/tests/parser_tests/test_microwatt_plru_tb_pp.vhd +93 -0
  128. data/tests/parser_tests/test_microwatt_ppc_fx_insns.vhd +1 -0
  129. data/tests/parser_tests/test_microwatt_ppc_fx_insns_pp.vhd +665 -0
  130. data/tests/parser_tests/test_microwatt_register_file.vhd +1 -0
  131. data/tests/parser_tests/test_microwatt_register_file_pp.vhd +86 -0
  132. data/tests/parser_tests/test_microwatt_rotator.vhd +1 -0
  133. data/tests/parser_tests/test_microwatt_rotator_pp.vhd +149 -0
  134. data/tests/parser_tests/test_microwatt_rotator_tb.vhd +1 -0
  135. data/tests/parser_tests/test_microwatt_rotator_tb_pp.vhd +134 -0
  136. data/tests/parser_tests/test_microwatt_sim_bram.vhd +1 -0
  137. data/tests/parser_tests/test_microwatt_sim_bram_helpers.vhd +1 -0
  138. data/tests/parser_tests/test_microwatt_sim_bram_helpers_pp.vhd +52 -0
  139. data/tests/parser_tests/test_microwatt_sim_bram_pp.vhd +53 -0
  140. data/tests/parser_tests/test_microwatt_sim_console.vhd +1 -0
  141. data/tests/parser_tests/test_microwatt_sim_console_pp.vhd +43 -0
  142. data/tests/parser_tests/test_microwatt_sim_jtag.vhd +1 -0
  143. data/tests/parser_tests/test_microwatt_sim_jtag_pp.vhd +64 -0
  144. data/tests/parser_tests/test_microwatt_sim_jtag_socket.vhd +1 -0
  145. data/tests/parser_tests/test_microwatt_sim_jtag_socket_pp.vhd +36 -0
  146. data/tests/parser_tests/test_microwatt_sim_uart.vhd +1 -0
  147. data/tests/parser_tests/test_microwatt_sim_uart_pp.vhd +90 -0
  148. data/tests/parser_tests/test_microwatt_soc.vhd +1 -0
  149. data/tests/parser_tests/test_microwatt_soc_pp.vhd +195 -0
  150. data/tests/parser_tests/test_microwatt_utils.vhd +1 -0
  151. data/tests/parser_tests/test_microwatt_utils_pp.vhd +39 -0
  152. data/tests/parser_tests/test_microwatt_wishbone_arbiter.vhd +1 -0
  153. data/tests/parser_tests/test_microwatt_wishbone_arbiter_pp.vhd +54 -0
  154. data/tests/parser_tests/test_microwatt_wishbone_bram_tb.vhd +1 -0
  155. data/tests/parser_tests/test_microwatt_wishbone_bram_tb_pp.vhd +157 -0
  156. data/tests/parser_tests/test_microwatt_wishbone_bram_wrapper.vhd +1 -0
  157. data/tests/parser_tests/test_microwatt_wishbone_bram_wrapper_pp.vhd +62 -0
  158. data/tests/parser_tests/test_microwatt_wishbone_debug_master.vhd +1 -0
  159. data/tests/parser_tests/test_microwatt_wishbone_debug_master_pp.vhd +124 -0
  160. data/tests/parser_tests/test_microwatt_wishbone_types.vhd +1 -0
  161. data/tests/parser_tests/test_microwatt_wishbone_types_pp.vhd +38 -0
  162. data/tests/parser_tests/test_microwatt_writeback.vhd +1 -0
  163. data/tests/parser_tests/test_microwatt_writeback_pp.vhd +87 -0
  164. data/tests/parser_tests/test_package-1.vhd +68 -0
  165. data/tests/parser_tests/test_package-1_pp.vhd +53 -0
  166. data/tests/parser_tests/test_precedence.vhd +13 -0
  167. data/tests/parser_tests/test_precedence_pp.vhd +16 -0
  168. data/tests/parser_tests/test_selected_sig.vhd +14 -0
  169. data/tests/parser_tests/test_selected_sig_pp.vhd +10 -0
  170. data/tests/parser_tests/test_slice.vhd +15 -0
  171. data/tests/parser_tests/test_slice_pp.vhd +16 -0
  172. data/tests/parser_tests/test_tb-00.vhd +94 -0
  173. data/tests/parser_tests/test_tb-00_pp.vhd +71 -0
  174. data/tests/parser_tests/test_type_decl_02.vhd +9 -0
  175. data/tests/parser_tests/test_type_decl_02_pp.vhd +11 -0
  176. data/tests/parser_tests/test_use.vhd +7 -0
  177. data/tests/parser_tests/test_use_pp.vhd +10 -0
  178. data/tests/parser_tests/test_while_1.vhd +38 -0
  179. data/tests/parser_tests/test_while_1_pp.vhd +26 -0
  180. data/tests/parser_tests/test_with-00.vhd +21 -0
  181. data/tests/parser_tests/test_with-00_pp.vhd +12 -0
  182. data/tests/tb_gen_tests/test_accelerator.vhd +160 -0
  183. metadata +224 -0
@@ -0,0 +1 @@
1
+ ../microwatt/utils.vhdl
@@ -0,0 +1,39 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ use ieee.numeric_std.all;
5
+
6
+ package utils is
7
+ function log2(i : natural) return integer
8
+ function log2ceil(i : natural) return integer
9
+ function ispow2(i : integer) return boolean
10
+
11
+ end utils;
12
+
13
+ package body utils is
14
+
15
+ function log2(i : natural) return integer is
16
+ variable tmp : integer := i;
17
+ variable ret : integer := 0;
18
+ begin
19
+ ;
20
+ return ret;
21
+ end function log2;
22
+
23
+ function log2ceil(i : natural) return integer is
24
+ variable tmp : integer := i;
25
+ variable ret : integer := 0;
26
+ begin
27
+ ;
28
+ return ret;
29
+ end function log2ceil;
30
+
31
+ function ispow2(i : integer) return boolean is
32
+ begin
33
+ if to_integer(to_unsigned(i,32) and to_unsigned(i - 1,32)) = 0 then
34
+ return true;
35
+ else
36
+ return false;
37
+ end if;
38
+ end function ispow2;
39
+ end utils;
@@ -0,0 +1 @@
1
+ ../microwatt/wishbone_arbiter.vhdl
@@ -0,0 +1,54 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ library work;
5
+ use work.wishbone_types.all;
6
+
7
+ entity wishbone_arbiter is
8
+ generic(
9
+ num_masters : positive3 := 3);
10
+ port(
11
+ clk : in std_ulogic;
12
+ rst : in std_ulogic;
13
+ wb_masters_in : in wishbone_master_out_vector(0 to num_masters - 1);
14
+ wb_masters_out : out wishbone_slave_out_vector(0 to num_masters - 1);
15
+ wb_slave_out : out wishbone_master_out;
16
+ wb_slave_in : in wishbone_slave_out);
17
+ end entity wishbone_arbiter;
18
+
19
+ architecture behave of wishbone_arbiter is
20
+
21
+ subtype wb_arb_master_t is integer range 0 to num_masters - 1;
22
+ signal candidate : wb_arb_master_t;
23
+ signal selected : wb_arb_master_t;
24
+ signal busy : std_ulogic;
25
+ begin
26
+
27
+ busy <= wb_masters_in(selected).cyc;
28
+
29
+ wishbone_muxes : process(selected,candidate,busy,wb_slave_in,wb_masters_in)
30
+ variable early_sel : wb_arb_master_t;
31
+ begin
32
+ early_sel := selected;
33
+ if busy = '0' then
34
+ early_sel := candidate;
35
+ end if;
36
+ wb_slave_out <= wb_masters_in(early_sel);
37
+ end process;
38
+
39
+ wishbone_candidate : process(all)
40
+ begin
41
+ candidate <= selected;
42
+ end process;
43
+
44
+ wishbone_arbiter_process : process(clk)
45
+ begin
46
+ if rising_edge(clk) then
47
+ if rst = '1' then
48
+ selected <= 0;
49
+ elsif busy = '0' then
50
+ selected <= candidate;
51
+ end if;
52
+ end if;
53
+ end process;
54
+ end behave;
@@ -0,0 +1 @@
1
+ ../microwatt/wishbone_bram_tb.vhdl
@@ -0,0 +1,157 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ use ieee.numeric_std.all;
5
+ library work;
6
+ use work.wishbone_types.all;
7
+
8
+ entity wishbone_bram_tb is
9
+ end entity wishbone_bram_tb;
10
+
11
+ architecture behave of wishbone_bram_tb is
12
+ signal clk : std_ulogic;
13
+ signal rst : std_ulogic := '1';
14
+ constant clk_period : time := 10 ns;
15
+ signal w_in : wishbone_slave_out;
16
+ signal w_out : wishbone_master_out;
17
+
18
+ function to_adr(a : integer) return std_ulogic_vector is
19
+ begin
20
+ return std_ulogic_vector(to_unsigned(a,w_out.adr'length));
21
+ end function to_adr;
22
+ begin
23
+
24
+ simple_ram_0 : entity work.wishbone_bram_wrapper
25
+ port map(
26
+ clk => clk,
27
+ rst => rst,
28
+ wishbone_out => w_in,
29
+ wishbone_in => w_out);
30
+
31
+
32
+ clock : process
33
+ begin
34
+ clk <= '1';
35
+ wait clk_period / 2;
36
+ clk <= '0';
37
+ wait clk_period / 2;
38
+ end process;
39
+
40
+ stim : process
41
+ begin
42
+ w_out.adr <= (others => '0');
43
+ w_out.dat <= (others => '0');
44
+ w_out.cyc <= '0';
45
+ w_out.stb <= '0';
46
+ w_out.sel <= (others => '0');
47
+ w_out.we <= '0';
48
+ wait rising_edge(clk);
49
+ rst <= '0';
50
+ wait rising_edge(clk);
51
+ w_out.cyc <= '1';
52
+ w_out.stb <= '1';
53
+ w_out.sel <= "11111111";
54
+ w_out.adr <= to_adr(0);
55
+ assert w_in.ack = '0';
56
+ wait rising_edge(clk);
57
+ w_out.stb <= '0';
58
+ wait rising_edge(clk);
59
+ wait rising_edge(clk);
60
+ assert w_in.ack = '1';
61
+ assert w_in.dat(63 downto 0) = x"0706050403020100"
62
+ report to_hstring(w_in.dat);
63
+ wait rising_edge(clk);
64
+ assert w_in.ack = '0';
65
+ w_out.stb <= '1';
66
+ w_out.sel <= "11111111";
67
+ w_out.adr <= to_adr(8);
68
+ assert w_in.ack = '0';
69
+ wait rising_edge(clk);
70
+ w_out.stb <= '0';
71
+ wait rising_edge(clk);
72
+ wait rising_edge(clk);
73
+ assert w_in.ack = '1';
74
+ assert w_in.dat(63 downto 0) = x"0f0e0d0c0b0a0908"
75
+ report to_hstring(w_in.dat);
76
+ wait rising_edge(clk);
77
+ assert w_in.ack = '0';
78
+ w_out.stb <= '1';
79
+ w_out.sel <= "00000001";
80
+ w_out.adr <= to_adr(0);
81
+ w_out.we <= '1';
82
+ w_out.dat(7 downto 0) <= x"0f";
83
+ assert w_in.ack = '0';
84
+ wait rising_edge(clk);
85
+ w_out.stb <= '0';
86
+ wait rising_edge(clk) and w_in.ack = '1';
87
+ wait rising_edge(clk);
88
+ assert w_in.ack = '0';
89
+ w_out.stb <= '1';
90
+ w_out.sel <= "11111111";
91
+ w_out.adr <= to_adr(0);
92
+ w_out.we <= '0';
93
+ assert w_in.ack = '0';
94
+ wait rising_edge(clk);
95
+ w_out.stb <= '0';
96
+ wait rising_edge(clk);
97
+ wait rising_edge(clk);
98
+ assert w_in.ack = '1';
99
+ assert w_in.dat(63 downto 0) = x"070605040302010f"
100
+ report to_hstring(w_in.dat);
101
+ wait rising_edge(clk);
102
+ assert w_in.ack = '0';
103
+ w_out.stb <= '1';
104
+ w_out.sel <= "11110000";
105
+ w_out.adr <= to_adr(0);
106
+ w_out.we <= '1';
107
+ w_out.dat(63 downto 32) <= x"baadfeed";
108
+ assert w_in.ack = '0';
109
+ wait rising_edge(clk);
110
+ w_out.stb <= '0';
111
+ wait rising_edge(clk) and w_in.ack = '1';
112
+ wait rising_edge(clk);
113
+ assert w_in.ack = '0';
114
+ w_out.stb <= '1';
115
+ w_out.sel <= "11111111";
116
+ w_out.adr <= to_adr(0);
117
+ w_out.we <= '0';
118
+ assert w_in.ack = '0';
119
+ wait rising_edge(clk);
120
+ w_out.stb <= '0';
121
+ wait rising_edge(clk);
122
+ wait rising_edge(clk);
123
+ assert w_in.ack = '1';
124
+ assert w_in.dat(63 downto 0) = x"baadfeed0302010f"
125
+ report to_hstring(w_in.dat);
126
+ wait rising_edge(clk);
127
+ assert w_in.ack = '0';
128
+ w_out.stb <= '1';
129
+ w_out.sel <= "11111111";
130
+ w_out.adr <= to_adr(8);
131
+ w_out.we <= '1';
132
+ w_out.dat(63 downto 0) <= x"0001020304050607";
133
+ assert w_in.ack = '0';
134
+ wait rising_edge(clk);
135
+ w_out.stb <= '0';
136
+ wait rising_edge(clk) and w_in.ack = '1';
137
+ wait rising_edge(clk);
138
+ assert w_in.ack = '0';
139
+ w_out.stb <= '1';
140
+ w_out.sel <= "11111111";
141
+ w_out.adr <= to_adr(8);
142
+ w_out.we <= '0';
143
+ assert w_in.ack = '0';
144
+ wait rising_edge(clk);
145
+ w_out.stb <= '0';
146
+ wait rising_edge(clk);
147
+ wait rising_edge(clk);
148
+ assert w_in.ack = '1';
149
+ assert w_in.dat(63 downto 0) = x"0001020304050607"
150
+ report to_hstring(w_in.dat);
151
+ wait rising_edge(clk);
152
+ assert w_in.ack = '0';
153
+ assert false
154
+ report "end of test" severity failure;
155
+ wait ;
156
+ end process;
157
+ end behave;
@@ -0,0 +1 @@
1
+ ../microwatt/wishbone_bram_wrapper.vhdl
@@ -0,0 +1,62 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ use ieee.numeric_std.all;
5
+ use std.textio.all;
6
+ library work;
7
+ use work.utils.all;
8
+ use work.wishbone_types.all;
9
+
10
+ entity wishbone_bram_wrapper is
11
+ generic(
12
+ memory_size : natural4096 := 4096;
13
+ ram_init_file : string);
14
+ port(
15
+ clk : in std_logic;
16
+ rst : in std_logic;
17
+ wishbone_in : in wishbone_master_out;
18
+ wishbone_out : out wishbone_slave_out);
19
+ end entity wishbone_bram_wrapper;
20
+
21
+ architecture behaviour of wishbone_bram_wrapper is
22
+ constant ram_addr_bits : integer := log2ceil(memory_size) - 3;
23
+ signal ram_addr : std_logic_vector(ram_addr_bits - 1 downto 0);
24
+ signal ram_we : std_ulogic;
25
+ signal ram_re : std_ulogic;
26
+ signal ack : std_ulogic;
27
+ signal ack_buf : std_ulogic;
28
+ begin
29
+
30
+ ram_0 : entity work.main_bram
31
+ port map(
32
+ clk => clk,
33
+ addr => ram_addr,
34
+ di => wishbone_in.dat,
35
+ do => wishbone_out.dat,
36
+ sel => wishbone_in.sel,
37
+ re => ram_re,
38
+ we => ram_we);
39
+
40
+ ram_addr <= wishbone_in.adr(ram_addr_bits + 2 downto 3);
41
+ ram_we <= wishbone_in.stb and wishbone_in.cyc and wishbone_in.we;
42
+ ram_re <= wishbone_in.stb and wishbone_in.cyc and wishbone_in.we;
43
+ wishbone_out.stall <= '0';
44
+ wishbone_out.ack <= ack_buf;
45
+
46
+ wb_0 : process(clk)
47
+ begin
48
+ if rising_edge(clk) then
49
+ if rst = '1' or wishbone_in.cyc = '0' then
50
+ ack_buf <= '0';
51
+ ack <= '0';
52
+ else
53
+ if ram_we = '1' and ack = '0' then
54
+ ack_buf <= '1';
55
+ else
56
+ ack <= wishbone_in.stb;
57
+ ack_buf <= ack;
58
+ end if;
59
+ end if;
60
+ end if;
61
+ end process;
62
+ end behaviour;
@@ -0,0 +1 @@
1
+ ../microwatt/wishbone_debug_master.vhdl
@@ -0,0 +1,124 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ use ieee.numeric_std.all;
5
+ library work;
6
+ use work.wishbone_types.all;
7
+
8
+ entity wishbone_debug_master is
9
+ port(
10
+ clk : in std_ulogic;
11
+ rst : in std_ulogic;
12
+ dmi_addr : in std_ulogic_vector(1 downto 0);
13
+ dmi_din : in std_ulogic_vector(63 downto 0);
14
+ dmi_dout : out std_ulogic_vector(63 downto 0);
15
+ dmi_req : in std_ulogic;
16
+ dmi_wr : in std_ulogic;
17
+ dmi_ack : out std_ulogic;
18
+ wb_out : out wishbone_master_out;
19
+ wb_in : in wishbone_slave_out);
20
+ end entity wishbone_debug_master;
21
+
22
+ architecture behaviour of wishbone_debug_master is
23
+ constant dbg_wb_addr : std_ulogic_vector(1 downto 0) := "00";
24
+ constant dbg_wb_data : std_ulogic_vector(1 downto 0) := "01";
25
+ constant dbg_wb_ctrl : std_ulogic_vector(1 downto 0) := "10";
26
+ constant dbg_wb_rsvd : std_ulogic_vector(1 downto 0) := "11";
27
+ signal reg_addr : std_ulogic_vector(63 downto 0);
28
+ signal reg_ctrl_out : std_ulogic_vector(63 downto 0);
29
+ signal reg_ctrl : std_ulogic_vector(10 downto 0);
30
+ signal data_latch : std_ulogic_vector(63 downto 0);
31
+
32
+ type state_t is (idle,wb_cycle,dmi_wait);
33
+ signal state : state_t;
34
+ begin
35
+
36
+ with dmi_addr select dmi_dout <=
37
+ reg_addr when dbg_wb_addr,
38
+ data_latch when dbg_wb_data,
39
+ reg_ctrl_out when dbg_wb_ctrl,
40
+ (others => '0') when others,;
41
+
42
+ reg_write : process(clk)
43
+
44
+ subtype autoinc_inc_t is integer range 1 to 8;
45
+
46
+ function decode_autoinc(c : std_ulogic_vector(1 downto 0)) return autoinc_inc_t is
47
+ begin
48
+ case c is
49
+ when "00" =>
50
+ return 1;
51
+ when "01" =>
52
+ return 2;
53
+ when "10" =>
54
+ return 4;
55
+ when "11" =>
56
+ return 8;
57
+ when others =>
58
+ return 8;
59
+ end case;
60
+ end function decode_autoinc;
61
+ begin
62
+ if rising_edge(clk) then
63
+ if (rst) then
64
+ reg_addr <= (others => '0');
65
+ reg_ctrl <= (others => '0');
66
+ else
67
+ if dmi_req and dmi_wr then
68
+ if dmi_addr = dbg_wb_addr then
69
+ reg_addr <= dmi_din;
70
+ elsif dmi_addr = dbg_wb_ctrl then
71
+ reg_ctrl <= dmi_din(10 downto 0);
72
+ end if;
73
+ elsif state = wb_cycle and (wb_in.ack and reg_ctrl(8)) = '1' then
74
+ reg_addr <= std_ulogic_vector(unsigned(reg_addr) + decode_autoinc(reg_ctrl(10 downto 9)));
75
+ end if;
76
+ end if;
77
+ end if;
78
+ end process;
79
+ dmi_ack <= dmi_req when (dmi_addr /= dbg_wb_data or state = dmi_wait) else '0';
80
+ wb_out.adr <= reg_addr(wb_out.adr'left downto 0);
81
+ wb_out.dat <= dmi_din;
82
+ wb_out.sel <= reg_ctrl(7 downto 0);
83
+ wb_out.we <= dmi_wr;
84
+ wb_out.cyc <= '1' when state = wb_cycle else '0';
85
+
86
+ latch_reads : process(clk)
87
+ begin
88
+ if rising_edge(clk) then
89
+ if state = wb_cycle and wb_in.ack = '1' and dmi_wr = '0' then
90
+ data_latch <= wb_in.dat;
91
+ end if;
92
+ end if;
93
+ end process;
94
+
95
+ wb_trigger : process(clk)
96
+ begin
97
+ if rising_edge(clk) then
98
+ if (rst) then
99
+ state <= idle;
100
+ wb_out.stb <= '0';
101
+ else
102
+ case state is
103
+ when idle =>
104
+ if dmi_req = '1' and dmi_addr = dbg_wb_data then
105
+ state <= wb_cycle;
106
+ wb_out.stb <= '1';
107
+ end if;
108
+ when wb_cycle =>
109
+ if wb_in.stall = '0' then
110
+ wb_out.stb <= '0';
111
+ end if;
112
+ if wb_in.ack then
113
+ wb_out.stb <= '0';
114
+ state <= dmi_wait;
115
+ end if;
116
+ when dmi_wait =>
117
+ if dmi_req = '0' then
118
+ state <= idle;
119
+ end if;
120
+ end case;
121
+ end if;
122
+ end if;
123
+ end process;
124
+ end behaviour;