-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# detect_lowest_high <br /> | ||
Created : 2021-5-20<br /> | ||
Author : Rongye<br /> | ||
Description : detect lowest high bit<br /> | ||
<br /> | ||
**.zip is the vivado project.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
`timescale 1ns / 1ps | ||
//================================================================================================== | ||
// Filename : detect_lowest_high .v | ||
// Created On : 2021-05-20 | ||
// Version : V 1.0 | ||
// Author : Rongye | ||
// Description : detect lowest high bit | ||
// Modification : | ||
// | ||
//================================================================================================== | ||
|
||
module DETECT_LOWEST_HIGH( | ||
// INPUTS | ||
Din, // 128bits | ||
// OUTPUTS | ||
Dout // 8 bits, MSB = 1 =>none of 1 | ||
); | ||
input [127:0] Din; | ||
output [7:0] Dout; | ||
|
||
reg [7:0] Dout; | ||
|
||
integer i; | ||
always@(*)begin | ||
Dout = 8'b1000_0000; | ||
for(i=127;i>=0;i=i-1) | ||
if(Din[i]==1'b1) | ||
Dout = i; | ||
else | ||
Dout = Dout; | ||
end | ||
endmodule |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
`timescale 1ns / 1ps | ||
`define Clock 20 // clock cycle | ||
////////////////////////////////////////////////////////////////////////////////// | ||
// Company: | ||
// Engineer: | ||
// | ||
// Create Date: 2021/05/20 09:42:55 | ||
// Design Name: | ||
// Module Name: DETECT_tb | ||
// Project Name: | ||
// Target Devices: | ||
// Tool Versions: | ||
// Description: | ||
// | ||
// Dependencies: | ||
// | ||
// Revision: | ||
// Revision 0.01 - File Created | ||
// Additional Comments: | ||
// | ||
////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
module DETECT_tb; | ||
// INPUTS | ||
reg [127:0] Din; // posedge active | ||
// OUTPUTS | ||
wire [7:0] Dout; // 8 bits | ||
|
||
DETECT_LOWEST_HIGH DETECT_LOWEST_HIGH_inst ( | ||
.Din (Din ), | ||
.Dout (Dout ) | ||
); | ||
|
||
initial begin | ||
#(`Clock*1); | ||
Din = 128'd1213213; // 100101000001100011101 Dout = 0 | ||
|
||
#(`Clock*5); | ||
Din = 128'd2223123513; // 10000100100000100010110000111001 Dout = 0 | ||
|
||
#(`Clock*5); | ||
Din = 128'd2; // 10 Dout = 1 | ||
|
||
#(`Clock*5); | ||
Din = 128'd4; // 100 Dout = 2 | ||
|
||
#(`Clock*5); | ||
Din = 128'd8; // 1000 Dout = 3 | ||
|
||
#(`Clock*5); | ||
Din = 128'd4444; // 1000101011100 Dout = 2 | ||
|
||
$stop; | ||
end | ||
endmodule | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.