Code Verilog - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module REG_BANK( M_O, A_IO, SEL, A_EN, M_EN, RW, CLOCK
) ;
output [ 7 : 0 ] M_O;
inout [ 7 : 0 ] A_IO;
input [ 2 : 0 ] SEL;
input A_EN, M_EN, RW, CLOCK;
reg [ 7 : 0 ] M_O, A_I;
reg [ 7 : 0 ] memblk [ 0 : 7 ] ;
assign A_IO = ( A_EN == 1'b1 && RW == 1'b0 ) ? A_I : A_IO; // NOT WORKING NOT UPDATING THE A_IO VALUE
always @ ( posedge CLOCK )
begin
if ( M_EN == 1'b0 )
M_O = 8'b00000000 ;
else if ( M_EN == 1'b1 && RW == 1'b0 )
begin
case ( SEL )
3'b000 : M_O = memblk[ 0 ] ;
3'b001 : M_O = memblk[ 1 ] ;
3'b010 : M_O = memblk[ 2 ] ;
3'b011 : M_O = memblk[ 3 ] ;
3'b100 : M_O = memblk[ 4 ] ;
3'b101 : M_O = memblk[ 5 ] ;
3'b110 : M_O = memblk[ 6 ] ;
3'b111 : M_O = memblk[ 7 ] ;
endcase
end
if ( A_EN == 1'b0 )
begin
end
else if ( A_EN == 1'b1 && RW == 1'b0 )
begin
case ( SEL )
3'b000 : A_I = memblk[ 0 ] ;
3'b001 : A_I = memblk[ 1 ] ;
3'b010 : A_I = memblk[ 2 ] ;
3'b011 : A_I = memblk[ 3 ] ;
3'b100 : A_I = memblk[ 4 ] ;
3'b101 : A_I = memblk[ 5 ] ;
3'b110 : A_I = memblk[ 6 ] ;
3'b111 : A_I = memblk[ 7 ] ;
endcase
end
else if ( A_EN == 1'b1 && RW == 1'b1 )
begin
case ( SEL )
3'b000 : memblk[ 0 ] = A_IO;
3'b001 : memblk[ 1 ] = A_IO;
3'b010 : memblk[ 2 ] = A_IO;
3'b011 : memblk[ 3 ] = A_IO;
3'b100 : memblk[ 4 ] = A_IO;
3'b101 : memblk[ 5 ] = A_IO;
3'b110 : memblk[ 6 ] = A_IO;
3'b111 : memblk[ 7 ] = A_IO;
endcase
end
end
endmodule
In the above program the A_IO value doesn't get updated during A_EN = 1 and RW = 0.
Pls help me.
Last edited by a moderator: Apr 21, 2014