File tree 4 files changed +9
-22
lines changed
4 files changed +9
-22
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ architecture arch of bp_1bit_predictor is
24
24
25
25
signal bht_table : bht_element_type;
26
26
signal prediction_internal : std_logic := '0' ;
27
- signal state : std_logic := NotTaken;
28
27
29
28
begin
30
29
prediction <= prediction_internal;
@@ -33,23 +32,20 @@ begin
33
32
variable idx : integer ;
34
33
begin
35
34
if reset = '1' then
36
- state <= NotTaken;
37
35
for i in 0 to 2 ** BHT_BITS loop
38
- bht_table(i) <= '0' ;
36
+ bht_table(i) <= NotTaken ;
39
37
end loop ;
40
38
elsif rising_edge (clock) then
41
39
if update = '1' then
42
40
idx := to_integer (unsigned (previous_pc(BHT_BITS + 1 downto 2 )));
43
- case state is
41
+ case bht_table(idx) is
44
42
when NotTaken =>
45
43
if prediction_incorrect = '1' then
46
- state <= Taken;
47
- bht_table(idx) <= NotTaken;
44
+ bht_table(idx) <= Taken;
48
45
end if ;
49
46
when Taken =>
50
47
if prediction_incorrect = '1' then
51
- state <= NotTaken;
52
- bht_table(idx) <= Taken;
48
+ bht_table(idx) <= NotTaken;
53
49
end if ;
54
50
when others =>
55
51
null ;
Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ architecture arch of bp_2bit_predictor is
25
25
constant NotTaken1 : std_logic_vector (1 downto 0 ) := "11" ;
26
26
27
27
signal bht_table : bht_element_type;
28
- signal prediction_internal : std_logic := '0' ;
29
- signal state : std_logic_vector (1 downto 0 ) := NotTaken1;
28
+ signal prediction_internal : std_logic := '0' ;
30
29
31
30
begin
32
31
prediction <= prediction_internal;
@@ -35,38 +34,31 @@ begin
35
34
variable idx : integer ;
36
35
begin
37
36
if reset = '1' then
38
- state <= NotTaken1;
39
37
for i in 0 to 2 ** BHT_BITS loop
40
38
bht_table(i) <= NotTaken1;
41
39
end loop ;
42
40
elsif rising_edge (clock) then
43
41
if update = '1' then
44
42
idx := to_integer (unsigned (previous_pc(BHT_BITS + 1 downto 2 )));
45
- case state is
43
+ case bht_table(idx) is
46
44
when NotTaken0 =>
47
45
if prediction_incorrect = '1' then
48
- state <= Taken1;
49
46
bht_table(idx) <= Taken1;
50
47
else
51
- state <= NotTaken1;
52
48
bht_table(idx) <= NotTaken1;
53
49
end if ;
54
50
when NotTaken1 =>
55
51
if prediction_incorrect = '1' then
56
- state <= NotTaken0;
57
52
bht_table(idx) <= NotTaken0;
58
53
end if ;
59
54
when Taken0 =>
60
55
if prediction_incorrect = '1' then
61
- state <= NotTaken1;
62
56
bht_table(idx) <= NotTaken1;
63
57
else
64
- state <= Taken1;
65
58
bht_table(idx) <= Taken1;
66
59
end if ;
67
60
when Taken1 =>
68
61
if prediction_incorrect = '1' then
69
- state <= Taken0;
70
62
bht_table(idx) <= Taken0;
71
63
end if ;
72
64
when others =>
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ package branch_prediction is
4
4
constant DEFAULT_BHT_BITS : integer := 12 ;
5
5
6
6
component bp_2bit_predictor is
7
- generic (BHT_BITS : integer );
7
+ generic (BHT_BITS : integer := DEFAULT_BHT_BITS );
8
8
port (
9
9
clock : in std_logic ;
10
10
reset : in std_logic ;
@@ -18,7 +18,7 @@ package branch_prediction is
18
18
end component bp_2bit_predictor ;
19
19
20
20
component bp_1bit_predictor is
21
- generic (BHT_BITS : integer );
21
+ generic (BHT_BITS : integer := DEFAULT_BHT_BITS );
22
22
port (
23
23
clock : in std_logic ;
24
24
reset : in std_logic ;
Original file line number Diff line number Diff line change @@ -289,8 +289,7 @@ begin
289
289
290
290
if_pc_plus_four <= std_logic_vector (unsigned (pc) + 4 );
291
291
292
- branch_predictor : bp_2bit_predictor
293
- generic map (BHT_BITS => DEFAULT_BHT_BITS)
292
+ branch_predictor : bp_1bit_predictor
294
293
port map (clock => clock,
295
294
reset => reset,
296
295
pc => pc,
You can’t perform that action at this time.
0 commit comments