Hello everyone.
Current Im designing 3x8 shift right SISO
Below is my verilog code:
1
`timescale1ns/1ps
2
moduleShiftReg(Clk,En,In,Out);
3
4
parameterInWidth=3;
5
parameterLength=8;
6
7
inputClk,En;
8
input[InWidth-1:0]In;
9
output[InWidth-1:0]Out;
10
11
reg[Length-1:0]sr;
12
13
always@(posedgeClk)
14
begin
15
if(En==1'b1)
16
begin
17
sr[0]<=In;
18
sr<=sr<<1;
19
end
20
end
21
22
assignOut=sr[Length-1];
23
24
endmodule
However this is my warning:
WARNING:HDLCompiler:413 -
"C:\Users\User\Desktop\PE\ShiftReg\ShiftReg\ShiftReg.v" Line 17: Result
of 3-bit expression is truncated to fit in 1-bit target.
WARNING:Xst:647 - Input <In> is never used. This port will be preserved
and left unconnected if it belongs to a top-level block or it belongs to
a sub-block and the hierarchy of this sub-block is preserved.
WARNING:Xst:1710 - FF/Latch <sr_0> (without init value) has a constant
value of 0 in block <ShiftReg>. This FF/Latch will be trimmed during the
optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_1>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_2>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_3>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_4>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_5>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_6>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_7>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1710 - FF/Latch <sr_0> (without init value) has a constant
value of 0 in block <ShiftReg>. This FF/Latch will be trimmed during the
optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_1>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_2>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_3>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_4>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_5>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_6>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <sr_7>
(without init value) has a constant value of 0 in block <ShiftReg>. This
FF/Latch will be trimmed during the optimization process.
Does anyone have any idea for my input problem?
Thank you very much
Dayana wrote:> However this is my warning:> WARNING:HDLCompiler:413 -> "C:\Users\User\Desktop\PE\ShiftReg\ShiftReg\ShiftReg.v" Line 17: Result> of 3-bit expression is truncated to fit in 1-bit target.
A hint: try to write your code without those generics/constants, but
with numbers in each signal and register definition. Then you will see,
that the line "sr[0] <= In;" is trying to pack a input vector "In" of
three bits width in a single flipflop "sr[0]".
What do you want to get with that code?
Should sr be a shift register to delay those In vectors?
Then you may have a look for "multidimensional arrays in Verilog":
https://www.google.com/search?q=multidimensional+arrays+in+veriloghttps://stackoverflow.com/questions/3011510/how-to-declare-and-use-1d-and-2d-byte-arrays-in-verilog
Dayana S. wrote:> Actually I want to preload my 3 bit data into my systolic array.
Do you want to store 3 bits in parallel (in 3 of those 8 bit shift
registers) or should they be stored one after the other in 1 shift
register? If the second: how do 8 bits length match with 3 input bits?
> Emmm I dont really understand the hint ...
Draw a structure of your shift register on a sheet of paper. Then we
have something to discuss about...
Tim wrote:> does it work in Simulation?
For sure not. You simply can't assign a input vector of 3 bits width to
a shift register with 1 bit width...
Dayana S. wrote:> Its a 3X8 Shift In Shift Out Register
At the moment you have a 1x8 Shift Register. As I said: you have to add
one dimension...
I don't do Verilog, but it should be something like that:
1
reg[Length-1:0][InWidth-1:0]sr;
At the end it should give an array of 24 flipflops arranged in some way
like 8x3...
> At the moment you have a 1x8 Shift Register. As I said: you have to add> one dimension...
Dimension?
> I don't do Verilog, but it should be something like that:reg> [Length-1:0][InWidth-1:0] sr;> At the end it should give an array of 24 flipflops arranged in some way> like 8x3...
Ive tried this but verilog doesnt used this type of operation? Maybe any
other idea?
Dayana S. wrote:> Maybe any other idea?
According to the link I posted earlier in this thread I would try it
this way:
reg [InWidth-1:0] sr [Length-1:0];
And if it's not working it would turn around the range:
reg [InWidth-1:0] sr [0:Length-1];
And if that doesn't do the job and if I were a student I would go to my
university's library and have a look for any Verilog book. It's in
there for sure...
Andi wrote:> Instead of a 2 dimensional array, you can also use a 24bit register and> shift by 3
And of course you can drive in a screw with a sledgehammer...
The one that doesn't like or doesn't understand 2-dimensional arrays,
that one may try it with 3 explicit shift registers like this:
Lothar M. wrote:> And of course you can drive in a screw with a sledgehammer...
Screws, hammers, nails or screwdrivers, at the end all is broken down to
LUTs and FlipFlops ;-)
The Verilog compiler will produce the same output, if you shift by 3,
shift 3 times by 1 or move an element of a 3bit two dimensinal array, so
why not take the one that is easiest to write.
Andi
Andi wrote:> Lothar M. wrote:>> And of course you can drive in a screw with a sledgehammer...> Screws, hammers, nails or screwdrivers, at the end all is broken down to> LUTs and FlipFlops ;-)
You are right, but Dayana now learned a workaround by hammering the
screw straightaway into the wall instead of selecting the correct tool
for the task.
And keep in mind: for one only knowing a hammer the whole world looks
like a nail. ;-)
> The Verilog compiler will produce the same output, if you shift by 3,> shift 3 times by 1 or move an element of a 3bit two dimensinal array, so> why not take the one that is easiest to write.
The "easiest" would be learning a bit about arrays and using them in the
future as the correct tool: