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/core.vhdl
@@ -0,0 +1 @@
1
+ ../microwatt/core_debug.vhdl
@@ -0,0 +1,104 @@
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.common.all;
7
+
8
+ entity core_debug is
9
+ port(
10
+ clk : in std_logic;
11
+ rst : in std_logic;
12
+ dmi_addr : in std_ulogic_vector(3 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
+ core_stop : out std_ulogic;
19
+ core_rst : out std_ulogic;
20
+ icache_rst : out std_ulogic;
21
+ terminate : in std_ulogic;
22
+ core_stopped : in std_ulogic;
23
+ nia : in std_ulogic_vector(63 downto 0);
24
+ terminated_out : out std_ulogic);
25
+ end entity core_debug;
26
+
27
+ architecture behave of core_debug is
28
+ signal dmi_req_1 : std_ulogic;
29
+ constant dbg_core_ctrl : std_ulogic_vector(3 downto 0) := "0000";
30
+ constant dbg_core_ctrl_stop : integer := 0;
31
+ constant dbg_core_ctrl_reset : integer := 1;
32
+ constant dbg_core_ctrl_icreset : integer := 2;
33
+ constant dbg_core_ctrl_step : integer := 3;
34
+ constant dbg_core_ctrl_start : integer := 4;
35
+ constant dbg_core_stat : std_ulogic_vector(3 downto 0) := "0001";
36
+ constant dbg_core_stat_stopping : integer := 0;
37
+ constant dbg_core_stat_stopped : integer := 1;
38
+ constant dbg_core_stat_term : integer := 2;
39
+ constant dbg_core_nia : std_ulogic_vector(3 downto 0) := "0010";
40
+ signal stat_reg : std_ulogic_vector(63 downto 0);
41
+ signal stopping : std_ulogic;
42
+ signal do_step : std_ulogic;
43
+ signal do_reset : std_ulogic;
44
+ signal do_icreset : std_ulogic;
45
+ signal terminated : std_ulogic;
46
+ begin
47
+
48
+ dmi_ack <= dmi_req;
49
+ stat_reg <= (2 => terminated,1 => core_stopped,0 => stopping,others => '0');
50
+ with dmi_addr select dmi_dout <=
51
+ stat_reg when dbg_core_stat,
52
+ nia when dbg_core_nia,
53
+ (others => '0') when others,;
54
+
55
+ reg_write : process(clk)
56
+ begin
57
+ if rising_edge(clk) then
58
+ do_step <= '0';
59
+ do_reset <= '0';
60
+ do_icreset <= '0';
61
+ if (rst) then
62
+ stopping <= '0';
63
+ terminated <= '0';
64
+ else
65
+ dmi_req_1 <= dmi_req;
66
+ if dmi_req = '1' and dmi_req_1 = '0' then
67
+ if dmi_wr = '1' then
68
+ report ("dmi write to " & to_hstring(dmi_addr));
69
+ if dmi_addr = dbg_core_ctrl then
70
+ if dmi_din(dbg_core_ctrl_reset) = '1' then
71
+ do_reset <= '1';
72
+ terminated <= '0';
73
+ end if;
74
+ if dmi_din(dbg_core_ctrl_stop) = '1' then
75
+ stopping <= '1';
76
+ end if;
77
+ if dmi_din(dbg_core_ctrl_step) = '1' then
78
+ do_step <= '1';
79
+ terminated <= '0';
80
+ end if;
81
+ if dmi_din(dbg_core_ctrl_icreset) = '1' then
82
+ do_icreset <= '1';
83
+ end if;
84
+ if dmi_din(dbg_core_ctrl_start) = '1' then
85
+ stopping <= '0';
86
+ terminated <= '0';
87
+ end if;
88
+ end if;
89
+ else
90
+ report ("dmi read from " & to_string(dmi_addr));
91
+ end if;
92
+ end if;
93
+ if terminate = '1' then
94
+ stopping <= '1';
95
+ terminated <= '1';
96
+ end if;
97
+ end if;
98
+ end if;
99
+ end process;
100
+ core_stop <= stopping and do_step;
101
+ core_rst <= do_reset;
102
+ icache_rst <= do_icreset;
103
+ terminated_out <= terminated;
104
+ end behave;
@@ -0,0 +1,231 @@
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.common.all;
7
+ use work.wishbone_types.all;
8
+
9
+ entity core is
10
+ generic(
11
+ sim : booleanfalse := false;
12
+ disable_flatten : booleanfalse := false;
13
+ ex1_bypass : booleantrue := true);
14
+ port(
15
+ clk : in std_logic;
16
+ rst : in std_logic;
17
+ wishbone_insn_in : in wishbone_slave_out;
18
+ wishbone_insn_out : out wishbone_master_out;
19
+ wishbone_data_in : in wishbone_slave_out;
20
+ wishbone_data_out : out wishbone_master_out;
21
+ dmi_addr : in std_ulogic_vector(3 downto 0);
22
+ dmi_din : in std_ulogic_vector(63 downto 0);
23
+ dmi_dout : out std_ulogic_vector(63 downto 0);
24
+ dmi_req : in std_ulogic;
25
+ dmi_wr : in std_ulogic;
26
+ dmi_ack : out std_ulogic;
27
+ terminated_out : out std_logic);
28
+ end entity core;
29
+
30
+ architecture behave of core is
31
+ signal fetch2_to_decode1 : fetch2todecode1type;
32
+ signal fetch1_to_icache : fetch1toicachetype;
33
+ signal icache_to_fetch2 : icachetofetch2type;
34
+ signal decode1_to_decode2 : decode1todecode2type;
35
+ signal decode2_to_execute1 : decode2toexecute1type;
36
+ signal register_file_to_decode2 : registerfiletodecode2type;
37
+ signal decode2_to_register_file : decode2toregisterfiletype;
38
+ signal writeback_to_register_file : writebacktoregisterfiletype;
39
+ signal decode2_to_cr_file : decode2tocrfiletype;
40
+ signal cr_file_to_decode2 : crfiletodecode2type;
41
+ signal writeback_to_cr_file : writebacktocrfiletype;
42
+ signal execute1_to_writeback : execute1towritebacktype;
43
+ signal execute1_to_fetch1 : execute1tofetch1type;
44
+ signal execute1_to_loadstore1 : execute1toloadstore1type;
45
+ signal loadstore1_to_writeback : loadstore1towritebacktype;
46
+ signal loadstore1_to_dcache : loadstore1todcachetype;
47
+ signal dcache_to_loadstore1 : dcachetoloadstore1type;
48
+ signal fetch1_stall_in : std_ulogic;
49
+ signal icache_stall_out : std_ulogic;
50
+ signal fetch2_stall_in : std_ulogic;
51
+ signal decode1_stall_in : std_ulogic;
52
+ signal decode2_stall_in : std_ulogic;
53
+ signal decode2_stall_out : std_ulogic;
54
+ signal ex1_icache_inval : std_ulogic;
55
+ signal ex1_stall_out : std_ulogic;
56
+ signal ls1_stall_out : std_ulogic;
57
+ signal dcache_stall_out : std_ulogic;
58
+ signal flush : std_ulogic;
59
+ signal complete : std_ulogic;
60
+ signal terminate : std_ulogic;
61
+ signal core_rst : std_ulogic;
62
+ signal icache_rst : std_ulogic;
63
+ signal sim_cr_dump : std_ulogic;
64
+ signal dbg_core_stop : std_ulogic;
65
+ signal dbg_core_rst : std_ulogic;
66
+ signal dbg_icache_rst : std_ulogic;
67
+ signal dbg_core_is_stopped : std_ulogic;
68
+
69
+ function keep_h(disable : boolean) return string is
70
+ begin
71
+ if disable then
72
+ return "yes";
73
+ else
74
+ return "no";
75
+ end if;
76
+ end function keep_h;
77
+ attribute keep_hierarchy : string;
78
+ attribute keep_hierarchy of fetch1_0 : label is keep_h(disable_flatten);
79
+ attribute keep_hierarchy of icache_0 : label is keep_h(disable_flatten);
80
+ attribute keep_hierarchy of fetch2_0 : label is keep_h(disable_flatten);
81
+ attribute keep_hierarchy of decode1_0 : label is keep_h(disable_flatten);
82
+ attribute keep_hierarchy of decode2_0 : label is keep_h(disable_flatten);
83
+ attribute keep_hierarchy of register_file_0 : label is keep_h(disable_flatten);
84
+ attribute keep_hierarchy of cr_file_0 : label is keep_h(disable_flatten);
85
+ attribute keep_hierarchy of execute1_0 : label is keep_h(disable_flatten);
86
+ attribute keep_hierarchy of loadstore1_0 : label is keep_h(disable_flatten);
87
+ attribute keep_hierarchy of dcache_0 : label is keep_h(disable_flatten);
88
+ attribute keep_hierarchy of writeback_0 : label is keep_h(disable_flatten);
89
+ attribute keep_hierarchy of debug_0 : label is keep_h(disable_flatten);
90
+ begin
91
+
92
+ core_rst <= dbg_core_rst or rst;
93
+ fetch1_0 : entity work.fetch1
94
+ port map(
95
+ clk => clk,
96
+ rst => core_rst,
97
+ stall_in => fetch1_stall_in,
98
+ flush_in => flush,
99
+ stop_in => dbg_core_stop,
100
+ e_in => execute1_to_fetch1,
101
+ i_out => fetch1_to_icache);
102
+
103
+ fetch1_stall_in <= icache_stall_out or decode2_stall_out;
104
+ icache_0 : entity work.icache
105
+ port map(
106
+ clk => clk,
107
+ rst => icache_rst,
108
+ i_in => fetch1_to_icache,
109
+ i_out => icache_to_fetch2,
110
+ flush_in => flush,
111
+ stall_out => icache_stall_out,
112
+ wishbone_out => wishbone_insn_out,
113
+ wishbone_in => wishbone_insn_in);
114
+
115
+ icache_rst <= rst or dbg_icache_rst or ex1_icache_inval;
116
+ fetch2_0 : entity work.fetch2
117
+ port map(
118
+ clk => clk,
119
+ rst => core_rst,
120
+ stall_in => fetch2_stall_in,
121
+ flush_in => flush,
122
+ i_in => icache_to_fetch2,
123
+ f_out => fetch2_to_decode1);
124
+
125
+ fetch2_stall_in <= decode2_stall_out;
126
+ decode1_0 : entity work.decode1
127
+ port map(
128
+ clk => clk,
129
+ rst => core_rst,
130
+ stall_in => decode1_stall_in,
131
+ flush_in => flush,
132
+ f_in => fetch2_to_decode1,
133
+ d_out => decode1_to_decode2);
134
+
135
+ decode1_stall_in <= decode2_stall_out;
136
+ decode2_0 : entity work.decode2
137
+ port map(
138
+ clk => clk,
139
+ rst => core_rst,
140
+ stall_in => decode2_stall_in,
141
+ stall_out => decode2_stall_out,
142
+ flush_in => flush,
143
+ complete_in => complete,
144
+ stopped_out => dbg_core_is_stopped,
145
+ d_in => decode1_to_decode2,
146
+ e_out => decode2_to_execute1,
147
+ r_in => register_file_to_decode2,
148
+ r_out => decode2_to_register_file,
149
+ c_in => cr_file_to_decode2,
150
+ c_out => decode2_to_cr_file);
151
+
152
+ decode2_stall_in <= ex1_stall_out or ls1_stall_out;
153
+ register_file_0 : entity work.register_file
154
+ port map(
155
+ clk => clk,
156
+ d_in => decode2_to_register_file,
157
+ d_out => register_file_to_decode2,
158
+ w_in => writeback_to_register_file,
159
+ sim_dump => terminate,
160
+ sim_dump_done => sim_cr_dump);
161
+
162
+ cr_file_0 : entity work.cr_file
163
+ port map(
164
+ clk => clk,
165
+ d_in => decode2_to_cr_file,
166
+ d_out => cr_file_to_decode2,
167
+ w_in => writeback_to_cr_file,
168
+ sim_dump => sim_cr_dump);
169
+
170
+ execute1_0 : entity work.execute1
171
+ port map(
172
+ clk => clk,
173
+ rst => core_rst,
174
+ flush_out => flush,
175
+ stall_out => ex1_stall_out,
176
+ e_in => decode2_to_execute1,
177
+ l_out => execute1_to_loadstore1,
178
+ f_out => execute1_to_fetch1,
179
+ e_out => execute1_to_writeback,
180
+ icache_inval => ex1_icache_inval,
181
+ terminate_out => terminate);
182
+
183
+ loadstore1_0 : entity work.loadstore1
184
+ port map(
185
+ clk => clk,
186
+ rst => core_rst,
187
+ l_in => execute1_to_loadstore1,
188
+ l_out => loadstore1_to_writeback,
189
+ d_out => loadstore1_to_dcache,
190
+ d_in => dcache_to_loadstore1,
191
+ dc_stall => dcache_stall_out,
192
+ stall_out => ls1_stall_out);
193
+
194
+ dcache_0 : entity work.dcache
195
+ port map(
196
+ clk => clk,
197
+ rst => core_rst,
198
+ d_in => loadstore1_to_dcache,
199
+ d_out => dcache_to_loadstore1,
200
+ stall_out => dcache_stall_out,
201
+ wishbone_in => wishbone_data_in,
202
+ wishbone_out => wishbone_data_out);
203
+
204
+ writeback_0 : entity work.writeback
205
+ port map(
206
+ clk => clk,
207
+ e_in => execute1_to_writeback,
208
+ l_in => loadstore1_to_writeback,
209
+ w_out => writeback_to_register_file,
210
+ c_out => writeback_to_cr_file,
211
+ complete_out => complete);
212
+
213
+ debug_0 : entity work.core_debug
214
+ port map(
215
+ clk => clk,
216
+ rst => rst,
217
+ dmi_addr => dmi_addr,
218
+ dmi_din => dmi_din,
219
+ dmi_dout => dmi_dout,
220
+ dmi_req => dmi_req,
221
+ dmi_wr => dmi_wr,
222
+ dmi_ack => dmi_ack,
223
+ core_stop => dbg_core_stop,
224
+ core_rst => dbg_core_rst,
225
+ icache_rst => dbg_icache_rst,
226
+ terminate => terminate,
227
+ core_stopped => dbg_core_is_stopped,
228
+ nia => fetch1_to_icache.nia,
229
+ terminated_out => terminated_out);
230
+
231
+ end behave;
@@ -0,0 +1 @@
1
+ ../microwatt/core_tb.vhdl
@@ -0,0 +1,43 @@
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.common.all;
7
+ use work.wishbone_types.all;
8
+
9
+ entity core_tb is
10
+ end entity core_tb;
11
+
12
+ architecture behave of core_tb is
13
+ signal clk : std_logic;
14
+ signal rst : std_logic;
15
+ constant clk_period : time := 10 ns;
16
+ begin
17
+
18
+ soc0 : entity work.soc
19
+ port map(
20
+ rst => rst,
21
+ system_clk => clk,
22
+ uart0_rxd => '0',
23
+ uart0_txd => open);
24
+
25
+
26
+ clk_process : process
27
+ begin
28
+ clk <= '0';
29
+ wait clk_period / 2;
30
+ clk <= '1';
31
+ wait clk_period / 2;
32
+ end process;
33
+
34
+ rst_process : process
35
+ begin
36
+ rst <= '1';
37
+ wait 10 * clk_period;
38
+ rst <= '0';
39
+ wait ;
40
+ end process;
41
+ jtag : entity work.sim_jtag
42
+
43
+ end behave;
@@ -0,0 +1 @@
1
+ ../microwatt/countzero.vhdl
@@ -0,0 +1,120 @@
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
+
7
+ entity zero_counter is
8
+ port(
9
+ clk : in std_logic;
10
+ rs : in std_ulogic_vector(63 downto 0);
11
+ count_right : in std_ulogic;
12
+ is_32bit : in std_ulogic;
13
+ result : out std_ulogic_vector(63 downto 0));
14
+ end entity zero_counter;
15
+
16
+ architecture behaviour of zero_counter is
17
+
18
+ type intermediate_result is record
19
+ v16 : std_ulogic_vector(15 downto 0);
20
+ sel_hi : std_ulogic_vector(1 downto 0);
21
+ is_32bit : std_ulogic;
22
+ count_right : std_ulogic;
23
+ end record;
24
+ signal r : intermediate_result;
25
+ signal r_in : intermediate_result;
26
+
27
+ function encoder(v : std_ulogic_vector(3 downto 0);right : std_ulogic) return std_ulogic_vector is
28
+ begin
29
+ if right = '0' then
30
+ if v(3) = '1' then
31
+ return "11";
32
+ elsif v(2) = '1' then
33
+ return "10";
34
+ elsif v(1) = '1' then
35
+ return "01";
36
+ else
37
+ return "00";
38
+ end if;
39
+ else
40
+ if v(0) = '1' then
41
+ return "00";
42
+ elsif v(1) = '1' then
43
+ return "01";
44
+ elsif v(2) = '1' then
45
+ return "10";
46
+ else
47
+ return "11";
48
+ end if;
49
+ end if;
50
+ end function encoder;
51
+ begin
52
+
53
+
54
+ zerocounter_0 : process(clk)
55
+ begin
56
+ if rising_edge(clk) then
57
+ r <= r_in;
58
+ end if;
59
+ end process;
60
+
61
+ zerocounter_1 : process(all)
62
+ variable v : intermediate_result;
63
+ variable y : std_ulogic_vector(3 downto 0);
64
+ variable z : std_ulogic_vector(3 downto 0);
65
+ variable sel : std_ulogic_vector(5 downto 0);
66
+ variable v4 : std_ulogic_vector(3 downto 0);
67
+ begin
68
+ z(0) := or(rs(15 downto 0));
69
+ z(1) := or(rs(31 downto 16));
70
+ z(2) := or(rs(47 downto 32));
71
+ z(3) := or(rs(63 downto 48));
72
+ if is_32bit = '0' then
73
+ v.sel_hi := encoder(z,count_right);
74
+ else
75
+ v.sel_hi(1) := '0';
76
+ if count_right = '0' then
77
+ v.sel_hi(0) := z(1);
78
+ else
79
+ v.sel_hi(0) := z(0);
80
+ end if;
81
+ end if;
82
+ case v.sel_hi is
83
+ when "00" =>
84
+ v.v16 := rs(15 downto 0);
85
+ when "01" =>
86
+ v.v16 := rs(31 downto 16);
87
+ when "10" =>
88
+ v.v16 := rs(47 downto 32);
89
+ when others =>
90
+ v.v16 := rs(63 downto 48);
91
+ end case;
92
+ v.is_32bit := is_32bit;
93
+ v.count_right := count_right;
94
+ r_in <= v;
95
+ sel(5 downto 4) := r.sel_hi;
96
+ y(0) := or(r.v16(3 downto 0));
97
+ y(1) := or(r.v16(7 downto 4));
98
+ y(2) := or(r.v16(11 downto 8));
99
+ y(3) := or(r.v16(15 downto 12));
100
+ sel(3 downto 2) := encoder(y,r.count_right);
101
+ case sel(3 downto 2) is
102
+ when "00" =>
103
+ v4 := r.v16(3 downto 0);
104
+ when "01" =>
105
+ v4 := r.v16(7 downto 4);
106
+ when "10" =>
107
+ v4 := r.v16(11 downto 8);
108
+ when others =>
109
+ v4 := r.v16(15 downto 12);
110
+ end case;
111
+ sel(1 downto 0) := encoder(v4,r.count_right);
112
+ if v4 = "0000" then
113
+ result <= x"00000000000000" & '0' & r.is_32bit & r.is_32bit & "00000";
114
+ elsif r.count_right = '0' then
115
+ result <= x"00000000000000" & "00" & (sel(5) and r.is_32bit) & sel(4 downto 0);
116
+ else
117
+ result <= x"00000000000000" & "00" & sel;
118
+ end if;
119
+ end process;
120
+ end behaviour;