vertigo_vhdl 0.8.6 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vertigo/parser.rb +28 -5
  3. data/lib/vertigo/tb_generator.rb +39 -18
  4. data/lib/vertigo/version.rb +1 -1
  5. data/tests/parser_tests/test_adder_rca_vhdl93.vhd +37 -0
  6. metadata +4 -85
  7. data/tests/ghdl_tests/test_fsm.vhd +0 -162
  8. data/tests/parser_tests/else.vhd +0 -64
  9. data/tests/parser_tests/pingpong.vhd +0 -34
  10. data/tests/parser_tests/test_accelerator_pp.vhd +0 -144
  11. data/tests/parser_tests/test_aggregate_pp.vhd +0 -15
  12. data/tests/parser_tests/test_archi_1_pp.vhd +0 -41
  13. data/tests/parser_tests/test_array_array_00_pp.vhd +0 -25
  14. data/tests/parser_tests/test_array_urange_pp.vhd +0 -25
  15. data/tests/parser_tests/test_chu-1_pp.vhd +0 -104
  16. data/tests/parser_tests/test_concat_pp.vhd +0 -14
  17. data/tests/parser_tests/test_counter_pp.vhd +0 -35
  18. data/tests/parser_tests/test_de2_pp.vhd +0 -274
  19. data/tests/parser_tests/test_encode_pp.vhd +0 -2549
  20. data/tests/parser_tests/test_fsm_pp.vhd +0 -125
  21. data/tests/parser_tests/test_fsm_synth_pp.vhd +0 -197
  22. data/tests/parser_tests/test_function-01_pp.vhd +0 -18
  23. data/tests/parser_tests/test_lfsr_pp.vhd +0 -44
  24. data/tests/parser_tests/test_microwatt_cache_ram_pp.vhd +0 -68
  25. data/tests/parser_tests/test_microwatt_common_pp.vhd +0 -336
  26. data/tests/parser_tests/test_microwatt_control_pp.vhd +0 -187
  27. data/tests/parser_tests/test_microwatt_core_debug_pp.vhd +0 -104
  28. data/tests/parser_tests/test_microwatt_core_pp.vhd +0 -231
  29. data/tests/parser_tests/test_microwatt_core_tb_pp.vhd +0 -43
  30. data/tests/parser_tests/test_microwatt_countzero_pp.vhd +0 -120
  31. data/tests/parser_tests/test_microwatt_countzero_tb_pp.vhd +0 -70
  32. data/tests/parser_tests/test_microwatt_cr_file_pp.vhd +0 -74
  33. data/tests/parser_tests/test_microwatt_cr_hazard_pp.vhd +0 -51
  34. data/tests/parser_tests/test_microwatt_crhelpers_pp.vhd +0 -48
  35. data/tests/parser_tests/test_microwatt_dcache_pp.vhd +0 -481
  36. data/tests/parser_tests/test_microwatt_dcache_tb_pp.vhd +0 -98
  37. data/tests/parser_tests/test_microwatt_decode1_pp.vhd +0 -138
  38. data/tests/parser_tests/test_microwatt_decode2_pp.vhd +0 -300
  39. data/tests/parser_tests/test_microwatt_decode_types_pp.vhd +0 -67
  40. data/tests/parser_tests/test_microwatt_divider_pp.vhd +0 -132
  41. data/tests/parser_tests/test_microwatt_divider_tb_pp.vhd +0 -95
  42. data/tests/parser_tests/test_microwatt_dmi_dtm_dummy_pp.vhd +0 -29
  43. data/tests/parser_tests/test_microwatt_dmi_dtm_tb_pp.vhd +0 -197
  44. data/tests/parser_tests/test_microwatt_dmi_dtm_xilinx_pp.vhd +0 -139
  45. data/tests/parser_tests/test_microwatt_execute1_pp.vhd +0 -689
  46. data/tests/parser_tests/test_microwatt_fetch1_pp.vhd +0 -88
  47. data/tests/parser_tests/test_microwatt_fetch2_pp.vhd +0 -79
  48. data/tests/parser_tests/test_microwatt_glibc_random_helpers_pp.vhd +0 -25
  49. data/tests/parser_tests/test_microwatt_glibc_random_pp.vhd +0 -41
  50. data/tests/parser_tests/test_microwatt_gpr_hazard_pp.vhd +0 -68
  51. data/tests/parser_tests/test_microwatt_helpers_pp.vhd +0 -153
  52. data/tests/parser_tests/test_microwatt_icache_pp.vhd +0 -337
  53. data/tests/parser_tests/test_microwatt_icache_tb_pp.vhd +0 -104
  54. data/tests/parser_tests/test_microwatt_insn_helpers_pp.vhd +0 -208
  55. data/tests/parser_tests/test_microwatt_loadstore1_pp.vhd +0 -222
  56. data/tests/parser_tests/test_microwatt_logical_pp.vhd +0 -87
  57. data/tests/parser_tests/test_microwatt_multiply_pp.vhd +0 -84
  58. data/tests/parser_tests/test_microwatt_multiply_tb_pp.vhd +0 -75
  59. data/tests/parser_tests/test_microwatt_plru_pp.vhd +0 -46
  60. data/tests/parser_tests/test_microwatt_plru_tb_pp.vhd +0 -93
  61. data/tests/parser_tests/test_microwatt_ppc_fx_insns_pp.vhd +0 -665
  62. data/tests/parser_tests/test_microwatt_register_file_pp.vhd +0 -86
  63. data/tests/parser_tests/test_microwatt_rotator_pp.vhd +0 -149
  64. data/tests/parser_tests/test_microwatt_rotator_tb_pp.vhd +0 -134
  65. data/tests/parser_tests/test_microwatt_sim_bram_helpers_pp.vhd +0 -52
  66. data/tests/parser_tests/test_microwatt_sim_bram_pp.vhd +0 -53
  67. data/tests/parser_tests/test_microwatt_sim_console_pp.vhd +0 -43
  68. data/tests/parser_tests/test_microwatt_sim_jtag_pp.vhd +0 -64
  69. data/tests/parser_tests/test_microwatt_sim_jtag_socket_pp.vhd +0 -36
  70. data/tests/parser_tests/test_microwatt_sim_uart_pp.vhd +0 -90
  71. data/tests/parser_tests/test_microwatt_soc_pp.vhd +0 -195
  72. data/tests/parser_tests/test_microwatt_utils_pp.vhd +0 -39
  73. data/tests/parser_tests/test_microwatt_wishbone_arbiter_pp.vhd +0 -54
  74. data/tests/parser_tests/test_microwatt_wishbone_bram_tb_pp.vhd +0 -157
  75. data/tests/parser_tests/test_microwatt_wishbone_bram_wrapper_pp.vhd +0 -62
  76. data/tests/parser_tests/test_microwatt_wishbone_debug_master_pp.vhd +0 -124
  77. data/tests/parser_tests/test_microwatt_wishbone_types_pp.vhd +0 -38
  78. data/tests/parser_tests/test_microwatt_writeback_pp.vhd +0 -87
  79. data/tests/parser_tests/test_package-1_pp.vhd +0 -53
  80. data/tests/parser_tests/test_precedence_pp.vhd +0 -16
  81. data/tests/parser_tests/test_selected_sig_pp.vhd +0 -10
  82. data/tests/parser_tests/test_slice_pp.vhd +0 -16
  83. data/tests/parser_tests/test_tb-00_pp.vhd +0 -71
  84. data/tests/parser_tests/test_type_decl_02_pp.vhd +0 -11
  85. data/tests/parser_tests/test_use_pp.vhd +0 -10
  86. data/tests/parser_tests/test_while_1_pp.vhd +0 -26
  87. data/tests/parser_tests/test_with-00_pp.vhd +0 -12
  88. data/tests/tb_gen_tests/test_accelerator.vhd +0 -160
@@ -1,124 +0,0 @@
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;
@@ -1,38 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- library ieee;
3
- use ieee.std_logic_1164.all;
4
-
5
- package wishbone_types is
6
- constant wishbone_addr_bits : integer := 32;
7
- constant wishbone_data_bits : integer := 64;
8
- constant wishbone_sel_bits : integer := wishbone_data_bits / 8;
9
-
10
- subtype wishbone_addr_type is std_ulogic_vector(wishbone_addr_bits - 1 downto 0);
11
-
12
- subtype wishbone_data_type is std_ulogic_vector(wishbone_data_bits - 1 downto 0);
13
-
14
- subtype wishbone_sel_type is std_ulogic_vector(wishbone_sel_bits - 1 downto 0);
15
-
16
- type wishbone_master_out is record
17
- adr : wishbone_addr_type;
18
- dat : wishbone_data_type;
19
- cyc : std_ulogic;
20
- stb : std_ulogic;
21
- sel : wishbone_sel_type;
22
- we : std_ulogic;
23
- end record;
24
- constant wishbone_master_out_init : wishbone_master_out := (cyc => '0',stb => '0',we => '0',others => (others => '0'));
25
-
26
- type wishbone_slave_out is record
27
- dat : wishbone_data_type;
28
- ack : std_ulogic;
29
- stall : std_ulogic;
30
- end record;
31
- constant wishbone_slave_out_init : wishbone_slave_out := (ack => '0',stall => '0',others => (others => '0'));
32
-
33
- type wishbone_master_out_vector is array(natural range <>) of wishbone_master_out;
34
-
35
- type wishbone_slave_out_vector is array(natural range <>) of wishbone_slave_out;
36
-
37
- end wishbone_types;
38
-
@@ -1,87 +0,0 @@
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.crhelpers.all;
8
-
9
- entity writeback is
10
- port(
11
- clk : in std_ulogic;
12
- e_in : in execute1towritebacktype;
13
- l_in : in loadstore1towritebacktype;
14
- w_out : out writebacktoregisterfiletype;
15
- c_out : out writebacktocrfiletype;
16
- complete_out : out std_ulogic);
17
- end entity writeback;
18
-
19
- architecture behaviour of writeback is
20
- begin
21
-
22
-
23
- writeback_1 : process(all)
24
- variable x : std_ulogic_vector(0 downto 0);
25
- variable y : std_ulogic_vector(0 downto 0);
26
- variable w : std_ulogic_vector(0 downto 0);
27
- variable cf : std_ulogic_vector(3 downto 0);
28
- variable zero : std_ulogic;
29
- variable sign : std_ulogic;
30
- variable scf : std_ulogic_vector(3 downto 0);
31
- begin
32
- x(0) := e_in.valid;
33
- y(0) := l_in.valid;
34
- assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1;
35
- x(0) := e_in.write_enable;
36
- y(0) := l_in.write_enable;
37
- assert (to_integer(unsigned(x)) + to_integer(unsigned(y))) <= 1;
38
- w(0) := e_in.write_cr_enable;
39
- x(0) := (e_in.write_enable and e_in.rc);
40
- assert (to_integer(unsigned(w)) + to_integer(unsigned(x))) <= 1;
41
- w_out <= writebacktoregisterfileinit;
42
- c_out <= writebacktocrfileinit;
43
- complete_out <= '0';
44
- if e_in.valid = '1' or l_in.valid = '1' then
45
- complete_out <= '1';
46
- end if;
47
- if e_in.write_enable = '1' then
48
- w_out.write_reg <= e_in.write_reg;
49
- w_out.write_data <= e_in.write_data;
50
- w_out.write_enable <= '1';
51
- end if;
52
- if e_in.write_cr_enable = '1' then
53
- c_out.write_cr_enable <= '1';
54
- c_out.write_cr_mask <= e_in.write_cr_mask;
55
- c_out.write_cr_data <= e_in.write_cr_data;
56
- end if;
57
- if e_in.write_xerc_enable = '1' then
58
- c_out.write_xerc_enable <= '1';
59
- c_out.write_xerc_data <= e_in.xerc;
60
- end if;
61
- if l_in.write_enable = '1' then
62
- w_out.write_reg <= gpr_to_gspr(l_in.write_reg);
63
- w_out.write_data <= l_in.write_data;
64
- w_out.write_enable <= '1';
65
- end if;
66
- if l_in.rc = '1' then
67
- scf(3) := '0';
68
- scf(2) := '0';
69
- scf(1) := l_in.store_done;
70
- scf(0) := l_in.xerc.so;
71
- c_out.write_cr_enable <= '1';
72
- c_out.write_cr_mask <= num_to_fxm(0);
73
- c_out.write_cr_data(31 downto 28) <= scf;
74
- end if;
75
- if e_in.rc = '1' and e_in.write_enable = '1' then
76
- sign := e_in.write_data(63);
77
- zero := (or(e_in.write_data));
78
- c_out.write_cr_enable <= '1';
79
- c_out.write_cr_mask <= num_to_fxm(0);
80
- cf(3) := sign;
81
- cf(2) := sign and zero;
82
- cf(1) := zero;
83
- cf(0) := e_in.xerc.so;
84
- c_out.write_cr_data(31 downto 28) <= cf;
85
- end if;
86
- end process;
87
- end behaviour;
@@ -1,53 +0,0 @@
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 alu_package is
7
- constant interval : time := 8 ns;
8
- signal sig_a : std_logic_vector(1 downto 0);
9
- signal sig_b : std_logic_vector(1 downto 0);
10
- signal sig_sel : std_logic_vector(1 downto 0);
11
- signal sig_res : std_logic_vector(1 downto 0);
12
-
13
- procedure load_data(
14
- a : out std_logic_vector(1 downto 0);
15
- b : out std_logic_vector(1 downto 0);
16
- sel : out std_logic_vector(1 downto 0));
17
-
18
- procedure check_data(
19
- sel : out std_logic_vector(1 downto 0));
20
-
21
- end alu_package;
22
-
23
- package body alu_package is
24
-
25
- procedure load_data(
26
- a : out std_logic_vector(1 downto 0);
27
- b : out std_logic_vector(1 downto 0);
28
- sel : out std_logic_vector(1 downto 0)) is
29
- begin
30
- a <= sig_a;
31
- b <= sig_b;
32
- sel <= sig_sel;
33
- end load_data;
34
-
35
- procedure check_data(
36
- sel : out std_logic_vector(1 downto 0)) is
37
- begin
38
- sel <= sig_sel;
39
- if (sig_sel = "00") then
40
- assert (sig_res = (sig_a + sig_b))
41
- report "error detected in addition!" severity warning;
42
- elsif (sig_sel = "01") then
43
- assert (sig_res = (sig_a - sig_b))
44
- report "error detected in subtraction!" severity warning;
45
- elsif (sig_sel = "10") then
46
- assert (sig_res = (sig_a and sig_b))
47
- report "and operation error!" severity warning;
48
- elsif (sig_sel = "11") then
49
- assert (sig_res = (sig_a or sig_b))
50
- report "or operation error!" severity warning;
51
- end if;
52
- end check_data;
53
- end alu_package;
@@ -1,16 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
-
3
- entity test is
4
- end entity test;
5
-
6
- architecture bhv of test is
7
- begin
8
-
9
-
10
- process
11
- begin
12
- if clk'event and clk = '1' then
13
- report "hourra!";
14
- end if;
15
- end process;
16
- end bhv;
@@ -1,10 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- architecture mux_4_vers_1 of porte_4_vers_1 is
3
- begin
4
-
5
- with adr select s <=
6
- a when "00",
7
- b when "01",
8
- c when "10",
9
- d when others,;
10
- end mux_4_vers_1;
@@ -1,16 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- library ieee;
3
- use ieee.std_logic_1164.all;
4
- use ieee.numeric_std.all;
5
-
6
- entity test is
7
- end entity test;
8
-
9
- architecture arch of test is
10
- constant cst : std_logic_vector(15 downto 0) := x"1234";
11
- signal s1 : std_logic_vector(31 downto 0);
12
- signal s2 : std_logic_vector(31 downto 0);
13
- begin
14
-
15
- s2 <= s1(15 downto 0) & cst;
16
- end arch;
@@ -1,71 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- library ieee;
3
- use ieee.std_logic_1164.all;
4
- use ieee.std_logic_arith.all;
5
-
6
- entity decoder_tb is
7
- end entity decoder_tb;
8
-
9
- architecture tb of decoder_tb is
10
- signal t_i : std_logic_vector(1 downto 0) := "00";
11
- signal t_o : std_logic_vector(3 downto 0);
12
- component decoder is
13
- port(
14
- i : in std_logic_vector(1 downto 0);
15
- o : out std_logic_vector(3 downto 0));
16
- end component;
17
- begin
18
-
19
- u_decoder : component decoder
20
- port map(
21
- t_i,
22
- t_o);
23
-
24
-
25
- process
26
- variable err_cnt : integer := 0;
27
- begin
28
- wait 10 ns;
29
- t_i <= "00";
30
- wait 1 ns;
31
- assert (t_o = "0001")
32
- report "error case 0" severity error;
33
- if (t_o /= "0001") then
34
- err_cnt := err_cnt + 1;
35
- end if;
36
- wait 10 ns;
37
- t_i <= "01";
38
- wait 1 ns;
39
- assert (t_o = "0010")
40
- report "error case 1" severity error;
41
- if (t_o /= "0010") then
42
- err_cnt := err_cnt + 1;
43
- end if;
44
- wait 10 ns;
45
- t_i <= "10";
46
- wait 1 ns;
47
- assert (t_o = "0100")
48
- report "error case 2" severity error;
49
- if (t_o /= "0100") then
50
- err_cnt := err_cnt + 1;
51
- end if;
52
- wait 10 ns;
53
- t_i <= "11";
54
- wait 1 ns;
55
- assert (t_o = "1000")
56
- report "error case 3" severity error;
57
- if (t_o /= "1000") then
58
- err_cnt := err_cnt + 1;
59
- end if;
60
- wait 10 ns;
61
- t_i <= "uu";
62
- if (err_cnt = 0) then
63
- assert false
64
- report "testbench of adder completed successfully!" severity note;
65
- else
66
- assert true
67
- report "something wrong, try again" severity error;
68
- end if;
69
- wait ;
70
- end process;
71
- end tb;
@@ -1,11 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
-
3
- entity test is
4
- end entity test;
5
-
6
- architecture test_var of test is
7
-
8
- type testit is array(natural range <>) of boolean;
9
- begin
10
-
11
- end test_var;
@@ -1,10 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- library ieee;
3
- library std;
4
- use ieee.std_logic_1164.all;
5
- use ieee.numeric_std.all;
6
- use work.accelerator_pkg.all;
7
-
8
- entity test is
9
- end entity test;
10
-
@@ -1,26 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- architecture test_while of while_tester is
3
- begin
4
-
5
-
6
- clk_1 : process(clock)
7
- begin
8
- ;
9
- end process;
10
-
11
- process
12
- begin
13
- ;
14
- end process;
15
-
16
- shift_3 : process(input_x)
17
- variable i : positive := 1;
18
- begin
19
- ;
20
- end process;
21
-
22
- shift_4 : process(input_x)
23
- begin
24
- ;
25
- end process;
26
- end test_while;
@@ -1,12 +0,0 @@
1
- -- generated by Vertigo VHDL tool
2
- architecture flow of ttimer is
3
- begin
4
-
5
- with s_sum select dig_sig1 <=
6
- "10000001" when 0,
7
- "11001111" when 1,
8
- "10010010" when 2,
9
- "10000110" when 3,
10
- "10000100" when 59,;
11
- dig_sig0 <= "10000001" when s_sum >= 0 and s_sum <= 9 else "11001111" when s_sum >= 10 and s_sum <= 19 else "10010010" when s_sum >= 20 and s_sum <= 29 else "10000110" when s_sum >= 30 and s_sum <= 39 else "11001100" when s_sum >= 40 and s_sum <= 49 else "10100100";
12
- end flow;
@@ -1,160 +0,0 @@
1
- library ieee,std;
2
- use ieee.std_logic_1164.all;
3
- use ieee.numeric_std.all;
4
- use work.accelerator_pkg.all;
5
-
6
- entity accelerator is
7
- port(
8
- clock : in std_logic;
9
- reset_n : in std_logic;
10
- bus_addr : in std_logic_vector(31 downto 0);
11
- bus_data_p2a : in std_logic_vector(31 downto 0);
12
- bus_data_a2p : out std_logic_vector(31 downto 0);
13
- bus_rd : in std_logic;
14
- bus_wr : in std_logic
15
- );
16
- end accelerator;
17
-
18
- architecture rtl of accelerator is
19
-
20
- type regs_t is record
21
- a, b, res : std_logic_vector(31 downto 0);
22
- ctrl : std_logic;
23
- status : std_logic_vector(1 downto 0); --busy,done
24
- end record;
25
-
26
- constant INIT_REGS : regs_t := (
27
- (others => '0'),
28
- (others => '0'),
29
- (others => '0'),
30
- '0',
31
- "00"
32
- );
33
-
34
- signal ifregs : regs_t;
35
-
36
- type state_t is (idle, running);
37
- signal state, state_c : state_t;
38
-
39
- type vars_t is record
40
- go : std_logic;
41
- a, b : unsigned(31 downto 0);
42
- done : std_logic;
43
- end record;
44
-
45
- -- constant VARS_INIT : vars_t := (
46
- -- '0',
47
- -- to_unsigned(0, 32),
48
- -- to_unsigned(0, 32),
49
- -- '0');
50
-
51
- signal vars, vars_c : vars_t;
52
-
53
- begin
54
- --========================================
55
- -- Bus interface
56
- --========================================
57
- bus_wr_proc : process(clk, reset_n)
58
- begin
59
- if reset_n = '0' then
60
- ifregs <= INIT_REGS;
61
- elsif rising_edge(clk) then
62
- ifregs.ctrl <= '0'; --autoreset
63
- if bus_wr = '1' then
64
- case bus_addr is
65
- when ADDR_A =>
66
- ifregs.a <= bus_data_p2a;
67
- when ADDR_B =>
68
- ifregs.b <= bus_data_p2a;
69
- when ADDR_CTRL =>
70
- ifregs.ctrl <= bus_data_p2a(0); --write/clear a go
71
- when ADDR_STATUS =>
72
- ifregs.status <= bus_data_p2a(1 downto 0); --clear rdy
73
- when others => null;
74
- end case;
75
- elsif vars.done = '1' then
76
- ifregs.res <= std_logic_vector(vars.a); --BUG : vars.a ne passait pas
77
- --=> FIX lexer : selected_name
78
- --ifregs.status(0) <= vars.done; --BUG : (0) ne passe pas
79
- ifregs.status <= vars.done; --BUG : (0) ne passe pas
80
- end if;
81
- end if;
82
- end process;
83
-
84
- bus_rd_proc : process(reset_n, clk)
85
- begin
86
- if reset_n = '0' then
87
- bus_data_a2p <= (others => '0');
88
- elsif rising_edge(clk) then
89
- if bus_rd = '1' then
90
- case bus_addr is
91
- when ADDR_A =>
92
- bus_data_a2p <= ifregs.a;
93
- when ADDR_B =>
94
- bus_data_a2p <= ifregs.b;
95
- when ADDR_CTRL =>
96
- null;
97
- --bus_data_a2p <= X"0000000" & "000" & ifregs.ctrl; --write/clear a go
98
- when ADDR_STATUS =>
99
- null;
100
- bus_data_a2p <= X"0000000" & "00" & ifregs.status;
101
- when ADDR_RES =>
102
- bus_data_a2p <= ifregs.res;
103
- when others => null;
104
- end case;
105
- end if;
106
- end if;
107
- end process;
108
-
109
- --=============================================
110
- -- BUG
111
- --=============================================
112
-
113
- reg : process(clk, reset_n)
114
- begin
115
- if reset_n = '0' then
116
- state <= idle;
117
- vars <= VARS_INIT;
118
- elsif rising_edge(clk) then
119
- state <= state_c;
120
- vars <= vars_c;
121
- if ifregs.ctrl = '1' then
122
- vars.a <= unsigned(ifregs.a);
123
- vars.b <= unsigned(ifregs.b);
124
- vars.go <= '1';
125
- end if;
126
- end if;
127
- end process;
128
-
129
- comb : process (state, vars)
130
- variable state_v : state_t;
131
- variable vars_v : vars_t;
132
- begin
133
- state_v := state;
134
- vars_v := vars;
135
- case state_v is
136
- when idle =>
137
- if vars_v.go = '1' then
138
- state_v := running;
139
- vars_v.go := '0';
140
- else
141
- vars_v := VARS_INIT;
142
- end if;
143
- when running =>
144
- if vars_v.a /= vars_v.b then
145
- if vars_v.a > vars_v.b then
146
- vars_v.a := vars_v.a-vars_v.b;
147
- else
148
- vars_v.b := vars_v.b-vars_v.a;
149
- end if;
150
- else
151
- vars_v.done := '1';
152
- state_v := idle;
153
- end if;
154
- when others => null;
155
- end case;
156
- state_c <= state_v;
157
- vars_c <= vars_v;
158
- end process;
159
-
160
- end rtl;