mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-30 15:00:26 +00:00
Add tests for Xilinx UG901 examples
This commit is contained in:
parent
0d037bf9d8
commit
2ae7dec530
89 changed files with 2962 additions and 0 deletions
42
tests/xilinx_ug901/squarediffmult.v
Normal file
42
tests/xilinx_ug901/squarediffmult.v
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Squarer support for DSP block (DSP48E2) with
|
||||
// pre-adder configured
|
||||
// as subtractor
|
||||
// File: squarediffmult.v
|
||||
|
||||
module squarediffmult # (parameter SIZEIN = 16)
|
||||
(
|
||||
input clk, ce, rst,
|
||||
input signed [SIZEIN-1:0] a, b,
|
||||
output signed [2*SIZEIN+1:0] square_out
|
||||
);
|
||||
|
||||
// Declare registers for intermediate values
|
||||
reg signed [SIZEIN-1:0] a_reg, b_reg;
|
||||
reg signed [SIZEIN:0] diff_reg;
|
||||
reg signed [2*SIZEIN+1:0] m_reg, p_reg;
|
||||
|
||||
always @(posedge clk)
|
||||
begin
|
||||
if (rst)
|
||||
begin
|
||||
a_reg <= 0;
|
||||
b_reg <= 0;
|
||||
diff_reg <= 0;
|
||||
m_reg <= 0;
|
||||
p_reg <= 0;
|
||||
end
|
||||
else
|
||||
if (ce)
|
||||
begin
|
||||
a_reg <= a;
|
||||
b_reg <= b;
|
||||
diff_reg <= a_reg - b_reg;
|
||||
m_reg <= diff_reg * diff_reg;
|
||||
p_reg <= m_reg;
|
||||
end
|
||||
end
|
||||
|
||||
// Output result
|
||||
assign square_out = p_reg;
|
||||
|
||||
endmodule // squarediffmult
|
Loading…
Add table
Add a link
Reference in a new issue