vertigo_vhdl 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,336 @@
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.decode_types.all;
7
+
8
+ package common is
9
+
10
+ subtype spr_num_t is integer range 0 to 1023;
11
+ function decode_spr_num(insn : std_ulogic_vector(31 downto 0)) return spr_num_t
12
+ constant spr_xer : spr_num_t := 1;
13
+ constant spr_lr : spr_num_t := 8;
14
+ constant spr_ctr : spr_num_t := 9;
15
+ constant spr_tb : spr_num_t := 268;
16
+ constant spr_dec : spr_num_t := 22;
17
+ constant spr_srr0 : spr_num_t := 26;
18
+ constant spr_srr1 : spr_num_t := 27;
19
+ constant spr_hsrr0 : spr_num_t := 314;
20
+ constant spr_hsrr1 : spr_num_t := 315;
21
+ constant spr_sprg0 : spr_num_t := 272;
22
+ constant spr_sprg1 : spr_num_t := 273;
23
+ constant spr_sprg2 : spr_num_t := 274;
24
+ constant spr_sprg3 : spr_num_t := 275;
25
+ constant spr_sprg3u : spr_num_t := 259;
26
+ constant spr_hsprg0 : spr_num_t := 304;
27
+ constant spr_hsprg1 : spr_num_t := 305;
28
+
29
+ subtype gpr_index_t is std_ulogic_vector(4 downto 0);
30
+
31
+ subtype gspr_index_t is std_ulogic_vector(5 downto 0);
32
+ function fast_spr_num(spr : spr_num_t) return gspr_index_t
33
+ function gspr_to_gpr(i : gspr_index_t) return gpr_index_t
34
+ function gpr_to_gspr(i : gpr_index_t) return gspr_index_t
35
+ function gpr_or_spr_to_gspr(g : gpr_index_t;s : gspr_index_t) return gspr_index_t
36
+ function is_fast_spr(s : gspr_index_t) return std_ulogic
37
+
38
+ type xer_common_t is record
39
+ ca : std_ulogic;
40
+ ca32 : std_ulogic;
41
+ ov : std_ulogic;
42
+ ov32 : std_ulogic;
43
+ so : std_ulogic;
44
+ end record;
45
+ constant xerc_init : xer_common_t := (others => '0');
46
+
47
+ type irq_state_t is (write_srr0,write_srr1);
48
+
49
+ type ctrl_t is record
50
+ tb : std_ulogic_vector(63 downto 0);
51
+ dec : std_ulogic_vector(63 downto 0);
52
+ msr : std_ulogic_vector(63 downto 0);
53
+ irq_state : irq_state_t;
54
+ irq_nia : std_ulogic_vector(63 downto 0);
55
+ srr1 : std_ulogic_vector(63 downto 0);
56
+ end record;
57
+
58
+ type fetch1toicachetype is record
59
+ req : std_ulogic;
60
+ stop_mark : std_ulogic;
61
+ nia : std_ulogic_vector(63 downto 0);
62
+ end record;
63
+
64
+ type icachetofetch2type is record
65
+ valid : std_ulogic;
66
+ stop_mark : std_ulogic;
67
+ nia : std_ulogic_vector(63 downto 0);
68
+ insn : std_ulogic_vector(31 downto 0);
69
+ end record;
70
+
71
+ type fetch2todecode1type is record
72
+ valid : std_ulogic;
73
+ stop_mark : std_ulogic;
74
+ nia : std_ulogic_vector(63 downto 0);
75
+ insn : std_ulogic_vector(31 downto 0);
76
+ end record;
77
+ constant fetch2todecode1init : fetch2todecode1type := (valid => '0',stop_mark => '0',others => (others => '0'));
78
+
79
+ type decode1todecode2type is record
80
+ valid : std_ulogic;
81
+ stop_mark : std_ulogic;
82
+ nia : std_ulogic_vector(63 downto 0);
83
+ insn : std_ulogic_vector(31 downto 0);
84
+ ispr1 : gspr_index_t;
85
+ ispr2 : gspr_index_t;
86
+ decode : decode_rom_t;
87
+ end record;
88
+ constant decode1todecode2init : decode1todecode2type := (valid => '0',stop_mark => '0',decode => decode_rom_init,others => (others => '0'));
89
+
90
+ type decode2toexecute1type is record
91
+ valid : std_ulogic;
92
+ insn_type : insn_type_t;
93
+ nia : std_ulogic_vector(63 downto 0);
94
+ write_reg : gspr_index_t;
95
+ read_reg1 : gspr_index_t;
96
+ read_reg2 : gspr_index_t;
97
+ read_data1 : std_ulogic_vector(63 downto 0);
98
+ read_data2 : std_ulogic_vector(63 downto 0);
99
+ read_data3 : std_ulogic_vector(63 downto 0);
100
+ bypass_data1 : std_ulogic;
101
+ bypass_data2 : std_ulogic;
102
+ bypass_data3 : std_ulogic;
103
+ cr : std_ulogic_vector(31 downto 0);
104
+ xerc : xer_common_t;
105
+ lr : std_ulogic;
106
+ rc : std_ulogic;
107
+ oe : std_ulogic;
108
+ invert_a : std_ulogic;
109
+ invert_out : std_ulogic;
110
+ input_carry : carry_in_t;
111
+ output_carry : std_ulogic;
112
+ input_cr : std_ulogic;
113
+ output_cr : std_ulogic;
114
+ is_32bit : std_ulogic;
115
+ is_signed : std_ulogic;
116
+ insn : std_ulogic_vector(31 downto 0);
117
+ data_len : std_ulogic_vector(3 downto 0);
118
+ byte_reverse : std_ulogic;
119
+ sign_extend : std_ulogic;
120
+ update : std_ulogic;
121
+ reserve : std_ulogic;
122
+ end record;
123
+ constant decode2toexecute1init : decode2toexecute1type := (valid => '0',insn_type => op_illegal,bypass_data1 => '0',bypass_data2 => '0',bypass_data3 => '0',lr => '0',rc => '0',oe => '0',invert_a => '0',invert_out => '0',input_carry => zero,output_carry => '0',input_cr => '0',output_cr => '0',is_32bit => '0',is_signed => '0',xerc => xerc_init,reserve => '0',byte_reverse => '0',sign_extend => '0',update => '0',others => (others => '0'));
124
+
125
+ type execute1tomultiplytype is record
126
+ valid : std_ulogic;
127
+ insn_type : insn_type_t;
128
+ data1 : std_ulogic_vector(64 downto 0);
129
+ data2 : std_ulogic_vector(64 downto 0);
130
+ is_32bit : std_ulogic;
131
+ end record;
132
+ constant execute1tomultiplyinit : execute1tomultiplytype := (valid => '0',insn_type => op_illegal,is_32bit => '0',others => (others => '0'));
133
+
134
+ type execute1todividertype is record
135
+ valid : std_ulogic;
136
+ dividend : std_ulogic_vector(63 downto 0);
137
+ divisor : std_ulogic_vector(63 downto 0);
138
+ is_signed : std_ulogic;
139
+ is_32bit : std_ulogic;
140
+ is_extended : std_ulogic;
141
+ is_modulus : std_ulogic;
142
+ neg_result : std_ulogic;
143
+ end record;
144
+ constant execute1todividerinit : execute1todividertype := (valid => '0',is_signed => '0',is_32bit => '0',is_extended => '0',is_modulus => '0',neg_result => '0',others => (others => '0'));
145
+
146
+ type decode2toregisterfiletype is record
147
+ read1_enable : std_ulogic;
148
+ read1_reg : gspr_index_t;
149
+ read2_enable : std_ulogic;
150
+ read2_reg : gspr_index_t;
151
+ read3_enable : std_ulogic;
152
+ read3_reg : gpr_index_t;
153
+ end record;
154
+
155
+ type registerfiletodecode2type is record
156
+ read1_data : std_ulogic_vector(63 downto 0);
157
+ read2_data : std_ulogic_vector(63 downto 0);
158
+ read3_data : std_ulogic_vector(63 downto 0);
159
+ end record;
160
+
161
+ type decode2tocrfiletype is record
162
+ read : std_ulogic;
163
+ end record;
164
+
165
+ type crfiletodecode2type is record
166
+ read_cr_data : std_ulogic_vector(31 downto 0);
167
+ read_xerc_data : xer_common_t;
168
+ end record;
169
+
170
+ type execute1tofetch1type is record
171
+ redirect : std_ulogic;
172
+ redirect_nia : std_ulogic_vector(63 downto 0);
173
+ end record;
174
+ constant execute1tofetch1typeinit : execute1tofetch1type := (redirect => '0',others => (others => '0'));
175
+
176
+ type execute1toloadstore1type is record
177
+ valid : std_ulogic;
178
+ load : std_ulogic;
179
+ addr1 : std_ulogic_vector(63 downto 0);
180
+ addr2 : std_ulogic_vector(63 downto 0);
181
+ data : std_ulogic_vector(63 downto 0);
182
+ write_reg : gpr_index_t;
183
+ length : std_ulogic_vector(3 downto 0);
184
+ ci : std_ulogic;
185
+ byte_reverse : std_ulogic;
186
+ sign_extend : std_ulogic;
187
+ update : std_ulogic;
188
+ update_reg : gpr_index_t;
189
+ xerc : xer_common_t;
190
+ reserve : std_ulogic;
191
+ rc : std_ulogic;
192
+ end record;
193
+ constant execute1toloadstore1init : execute1toloadstore1type := (valid => '0',load => '0',ci => '0',byte_reverse => '0',sign_extend => '0',update => '0',xerc => xerc_init,reserve => '0',rc => '0',others => (others => '0'));
194
+
195
+ type loadstore1todcachetype is record
196
+ valid : std_ulogic;
197
+ load : std_ulogic;
198
+ nc : std_ulogic;
199
+ reserve : std_ulogic;
200
+ addr : std_ulogic_vector(63 downto 0);
201
+ data : std_ulogic_vector(63 downto 0);
202
+ byte_sel : std_ulogic_vector(7 downto 0);
203
+ end record;
204
+
205
+ type dcachetoloadstore1type is record
206
+ valid : std_ulogic;
207
+ data : std_ulogic_vector(63 downto 0);
208
+ store_done : std_ulogic;
209
+ error : std_ulogic;
210
+ end record;
211
+
212
+ type loadstore1towritebacktype is record
213
+ valid : std_ulogic;
214
+ write_enable : std_ulogic;
215
+ write_reg : gpr_index_t;
216
+ write_data : std_ulogic_vector(63 downto 0);
217
+ xerc : xer_common_t;
218
+ rc : std_ulogic;
219
+ store_done : std_ulogic;
220
+ end record;
221
+ constant loadstore1towritebackinit : loadstore1towritebacktype := (valid => '0',write_enable => '0',xerc => xerc_init,rc => '0',store_done => '0',others => (others => '0'));
222
+
223
+ type execute1towritebacktype is record
224
+ valid : std_ulogic;
225
+ rc : std_ulogic;
226
+ write_enable : std_ulogic;
227
+ write_reg : gspr_index_t;
228
+ write_data : std_ulogic_vector(63 downto 0);
229
+ write_cr_enable : std_ulogic;
230
+ write_cr_mask : std_ulogic_vector(7 downto 0);
231
+ write_cr_data : std_ulogic_vector(31 downto 0);
232
+ write_xerc_enable : std_ulogic;
233
+ xerc : xer_common_t;
234
+ end record;
235
+ constant execute1towritebackinit : execute1towritebacktype := (valid => '0',rc => '0',write_enable => '0',write_cr_enable => '0',write_xerc_enable => '0',xerc => xerc_init,others => (others => '0'));
236
+
237
+ type multiplytoexecute1type is record
238
+ valid : std_ulogic;
239
+ write_reg_data : std_ulogic_vector(63 downto 0);
240
+ overflow : std_ulogic;
241
+ end record;
242
+ constant multiplytoexecute1init : multiplytoexecute1type := (valid => '0',overflow => '0',others => (others => '0'));
243
+
244
+ type dividertoexecute1type is record
245
+ valid : std_ulogic;
246
+ write_reg_data : std_ulogic_vector(63 downto 0);
247
+ overflow : std_ulogic;
248
+ end record;
249
+ constant dividertoexecute1init : dividertoexecute1type := (valid => '0',overflow => '0',others => (others => '0'));
250
+
251
+ type writebacktoregisterfiletype is record
252
+ write_reg : gspr_index_t;
253
+ write_data : std_ulogic_vector(63 downto 0);
254
+ write_enable : std_ulogic;
255
+ end record;
256
+ constant writebacktoregisterfileinit : writebacktoregisterfiletype := (write_enable => '0',others => (others => '0'));
257
+
258
+ type writebacktocrfiletype is record
259
+ write_cr_enable : std_ulogic;
260
+ write_cr_mask : std_ulogic_vector(7 downto 0);
261
+ write_cr_data : std_ulogic_vector(31 downto 0);
262
+ write_xerc_enable : std_ulogic;
263
+ write_xerc_data : xer_common_t;
264
+ end record;
265
+ constant writebacktocrfileinit : writebacktocrfiletype := (write_cr_enable => '0',write_xerc_enable => '0',write_xerc_data => xerc_init,others => (others => '0'));
266
+
267
+ end common;
268
+
269
+ package body common is
270
+
271
+ function decode_spr_num(insn : std_ulogic_vector(31 downto 0)) return spr_num_t is
272
+ begin
273
+ return to_integer(unsigned(insn(15 downto 11) & insn(20 downto 16)));
274
+ end function decode_spr_num;
275
+
276
+ function fast_spr_num(spr : spr_num_t) return gspr_index_t is
277
+ variable n : integer range 0 to 31;
278
+ begin
279
+ case spr is
280
+ when spr_lr =>
281
+ n := 0;
282
+ when spr_ctr =>
283
+ n := 1;
284
+ when spr_srr0 =>
285
+ n := 2;
286
+ when spr_srr1 =>
287
+ n := 3;
288
+ when spr_hsrr0 =>
289
+ n := 4;
290
+ when spr_hsrr1 =>
291
+ n := 5;
292
+ when spr_sprg0 =>
293
+ n := 6;
294
+ when spr_sprg1 =>
295
+ n := 7;
296
+ when spr_sprg2 =>
297
+ n := 8;
298
+ when spr_sprg3 | spr_sprg3u =>
299
+ n := 9;
300
+ when spr_hsprg0 =>
301
+ n := 10;
302
+ when spr_hsprg1 =>
303
+ n := 11;
304
+ when spr_xer =>
305
+ n := 12;
306
+ when others =>
307
+ n := 0;
308
+ return "000000";
309
+ end case;
310
+ return "1" & std_ulogic_vector(to_unsigned(n,5));
311
+ end function fast_spr_num;
312
+
313
+ function gspr_to_gpr(i : gspr_index_t) return gpr_index_t is
314
+ begin
315
+ return i(4 downto 0);
316
+ end function gspr_to_gpr;
317
+
318
+ function gpr_to_gspr(i : gpr_index_t) return gspr_index_t is
319
+ begin
320
+ return "0" & i;
321
+ end function gpr_to_gspr;
322
+
323
+ function gpr_or_spr_to_gspr(g : gpr_index_t;s : gspr_index_t) return gspr_index_t is
324
+ begin
325
+ if s(5) = '1' then
326
+ return s;
327
+ else
328
+ return gpr_to_gspr(g);
329
+ end if;
330
+ end function gpr_or_spr_to_gspr;
331
+
332
+ function is_fast_spr(s : gspr_index_t) return std_ulogic is
333
+ begin
334
+ return s(5);
335
+ end function is_fast_spr;
336
+ end common;
@@ -0,0 +1 @@
1
+ ../microwatt/control.vhdl
@@ -0,0 +1,187 @@
1
+ -- generated by Vertigo VHDL tool
2
+ library ieee;
3
+ use ieee.std_logic_1164.all;
4
+ library work;
5
+ use work.common.all;
6
+
7
+ entity control is
8
+ generic(
9
+ pipeline_depth : natural2 := 2);
10
+ port(
11
+ clk : in std_ulogic;
12
+ rst : in std_ulogic;
13
+ complete_in : in std_ulogic;
14
+ valid_in : in std_ulogic;
15
+ flush_in : in std_ulogic;
16
+ stall_in : in std_ulogic;
17
+ sgl_pipe_in : in std_ulogic;
18
+ stop_mark_in : in std_ulogic;
19
+ gpr_write_valid_in : in std_ulogic;
20
+ gpr_write_in : in gspr_index_t;
21
+ gpr_bypassable : in std_ulogic;
22
+ gpr_a_read_valid_in : in std_ulogic;
23
+ gpr_a_read_in : in gspr_index_t;
24
+ gpr_b_read_valid_in : in std_ulogic;
25
+ gpr_b_read_in : in gspr_index_t;
26
+ gpr_c_read_valid_in : in std_ulogic;
27
+ gpr_c_read_in : in gpr_index_t;
28
+ cr_read_in : in std_ulogic;
29
+ cr_write_in : in std_ulogic;
30
+ valid_out : out std_ulogic;
31
+ stall_out : out std_ulogic;
32
+ stopped_out : out std_ulogic;
33
+ gpr_bypass_a : out std_ulogic;
34
+ gpr_bypass_b : out std_ulogic;
35
+ gpr_bypass_c : out std_ulogic);
36
+ end entity control;
37
+
38
+ architecture rtl of control is
39
+
40
+ type state_type is (idle,wait_for_prev_to_complete,wait_for_curr_to_complete);
41
+
42
+ type reg_internal_type is record
43
+ state : state_type;
44
+ outstanding : integer range 1 to pipeline_depth + 2;
45
+ end record;
46
+ constant reg_internal_init : reg_internal_type := (state => idle,outstanding => 0);
47
+ signal r_int : reg_internal_type;
48
+ signal rin_int : reg_internal_type := reg_internal_init;
49
+ signal stall_a_out : std_ulogic;
50
+ signal stall_b_out : std_ulogic;
51
+ signal stall_c_out : std_ulogic;
52
+ signal cr_stall_out : std_ulogic;
53
+ signal gpr_write_valid : std_ulogic := '0';
54
+ signal cr_write_valid : std_ulogic := '0';
55
+ signal gpr_c_read_in_fmt : std_ulogic_vector(5 downto 0);
56
+ begin
57
+
58
+ gpr_hazard0 : entity work.gpr_hazard
59
+ port map(
60
+ clk => clk,
61
+ stall_in => stall_in,
62
+ gpr_write_valid_in => gpr_write_valid,
63
+ gpr_write_in => gpr_write_in,
64
+ bypass_avail => gpr_bypassable,
65
+ gpr_read_valid_in => gpr_a_read_valid_in,
66
+ gpr_read_in => gpr_a_read_in,
67
+ stall_out => stall_a_out,
68
+ use_bypass => gpr_bypass_a);
69
+
70
+ gpr_hazard1 : entity work.gpr_hazard
71
+ port map(
72
+ clk => clk,
73
+ stall_in => stall_in,
74
+ gpr_write_valid_in => gpr_write_valid,
75
+ gpr_write_in => gpr_write_in,
76
+ bypass_avail => gpr_bypassable,
77
+ gpr_read_valid_in => gpr_b_read_valid_in,
78
+ gpr_read_in => gpr_b_read_in,
79
+ stall_out => stall_b_out,
80
+ use_bypass => gpr_bypass_b);
81
+
82
+ gpr_c_read_in_fmt <= "0" & gpr_c_read_in;
83
+ gpr_hazard2 : entity work.gpr_hazard
84
+ port map(
85
+ clk => clk,
86
+ stall_in => stall_in,
87
+ gpr_write_valid_in => gpr_write_valid,
88
+ gpr_write_in => gpr_write_in,
89
+ bypass_avail => gpr_bypassable,
90
+ gpr_read_valid_in => gpr_c_read_valid_in,
91
+ gpr_read_in => gpr_c_read_in_fmt,
92
+ stall_out => stall_c_out,
93
+ use_bypass => gpr_bypass_c);
94
+
95
+ cr_hazard0 : entity work.cr_hazard
96
+ port map(
97
+ clk => clk,
98
+ stall_in => stall_in,
99
+ cr_read_in => cr_read_in,
100
+ cr_write_in => cr_write_valid,
101
+ stall_out => cr_stall_out);
102
+
103
+
104
+ control0 : process(clk)
105
+ begin
106
+ if rising_edge(clk) then
107
+ assert r_int.outstanding >= 0 and r_int.outstanding <= (pipeline_depth + 1)
108
+ report "outstanding bad " & integer'image(r_int.outstanding) severity failure;
109
+ r_int <= rin_int;
110
+ end if;
111
+ end process;
112
+
113
+ control1 : process(all)
114
+ variable v_int : reg_internal_type;
115
+ variable valid_tmp : std_ulogic;
116
+ variable stall_tmp : std_ulogic;
117
+ begin
118
+ v_int := r_int;
119
+ valid_tmp := valid_in and flush_in and stall_in;
120
+ stall_tmp := stall_in;
121
+ if complete_in = '1' then
122
+ v_int.outstanding := r_int.outstanding - 1;
123
+ end if;
124
+ stopped_out <= '0';
125
+ if stop_mark_in = '1' and v_int.outstanding = 0 then
126
+ stopped_out <= '1';
127
+ end if;
128
+ case r_int.state is
129
+ when idle =>
130
+ if valid_tmp = '1' then
131
+ if (sgl_pipe_in = '1') then
132
+ if v_int.outstanding /= 0 then
133
+ v_int.state := wait_for_prev_to_complete;
134
+ stall_tmp := '1';
135
+ else
136
+ v_int.state := wait_for_curr_to_complete;
137
+ end if;
138
+ else
139
+ stall_tmp := stall_a_out or stall_b_out or stall_c_out or cr_stall_out;
140
+ end if;
141
+ end if;
142
+ when wait_for_prev_to_complete =>
143
+ if v_int.outstanding = 0 then
144
+ v_int.state := wait_for_curr_to_complete;
145
+ else
146
+ stall_tmp := '1';
147
+ end if;
148
+ when wait_for_curr_to_complete =>
149
+ if v_int.outstanding = 0 then
150
+ v_int.state := idle;
151
+ if valid_tmp = '1' then
152
+ if (sgl_pipe_in = '1') then
153
+ if v_int.outstanding /= 0 then
154
+ v_int.state := wait_for_prev_to_complete;
155
+ stall_tmp := '1';
156
+ else
157
+ v_int.state := wait_for_curr_to_complete;
158
+ end if;
159
+ else
160
+ stall_tmp := stall_a_out or stall_b_out or stall_c_out or cr_stall_out;
161
+ end if;
162
+ end if;
163
+ else
164
+ stall_tmp := '1';
165
+ end if;
166
+ end case;
167
+ if stall_tmp = '1' then
168
+ valid_tmp := '0';
169
+ end if;
170
+ if valid_tmp = '1' then
171
+ v_int.outstanding := v_int.outstanding + 1;
172
+ gpr_write_valid <= gpr_write_valid_in;
173
+ cr_write_valid <= cr_write_in;
174
+ else
175
+ gpr_write_valid <= '0';
176
+ cr_write_valid <= '0';
177
+ end if;
178
+ if rst = '1' then
179
+ v_int.state := idle;
180
+ v_int.outstanding := 0;
181
+ stall_tmp := '0';
182
+ end if;
183
+ valid_out <= valid_tmp;
184
+ stall_out <= stall_tmp;
185
+ rin_int <= v_int;
186
+ end process;
187
+ end rtl;