1 RTL代码
module top_compare(
input I_sys_clk,
input I_reset_n,
input [3:0] I_a ,
input [3:0] I_b ,
output reg O_greater,
output reg O_less ,
output reg O_equal
);
always @(posedge I_sys_clk or negedge I_reset_n)
begin
if(~I_reset_n)
begin
O_greater I_b[6:5] ? 1 : 0。最终,如果I_a > I_b,则CO[3] == 1。否则等于0。
#mermaid-svg-JPhGR2zGtQxHILsj .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-JPhGR2zGtQxHILsj .label text{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .node rect,#mermaid-svg-JPhGR2zGtQxHILsj .node circle,#mermaid-svg-JPhGR2zGtQxHILsj .node ellipse,#mermaid-svg-JPhGR2zGtQxHILsj .node polygon,#mermaid-svg-JPhGR2zGtQxHILsj .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-JPhGR2zGtQxHILsj .node .label{text-align:center;fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .node.clickable{cursor:pointer}#mermaid-svg-JPhGR2zGtQxHILsj .arrowheadPath{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-JPhGR2zGtQxHILsj .flowchart-link{stroke:#333;fill:none}#mermaid-svg-JPhGR2zGtQxHILsj .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-JPhGR2zGtQxHILsj .edgeLabel rect{opacity:0.9}#mermaid-svg-JPhGR2zGtQxHILsj .edgeLabel span{color:#333}#mermaid-svg-JPhGR2zGtQxHILsj .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-JPhGR2zGtQxHILsj .cluster text{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-JPhGR2zGtQxHILsj .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-JPhGR2zGtQxHILsj text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-JPhGR2zGtQxHILsj .actor-line{stroke:grey}#mermaid-svg-JPhGR2zGtQxHILsj .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-JPhGR2zGtQxHILsj .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-JPhGR2zGtQxHILsj #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-JPhGR2zGtQxHILsj .sequenceNumber{fill:#fff}#mermaid-svg-JPhGR2zGtQxHILsj #sequencenumber{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj #crosshead path{fill:#333;stroke:#333}#mermaid-svg-JPhGR2zGtQxHILsj .messageText{fill:#333;stroke:#333}#mermaid-svg-JPhGR2zGtQxHILsj .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-JPhGR2zGtQxHILsj .labelText,#mermaid-svg-JPhGR2zGtQxHILsj .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-JPhGR2zGtQxHILsj .loopText,#mermaid-svg-JPhGR2zGtQxHILsj .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-JPhGR2zGtQxHILsj .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-JPhGR2zGtQxHILsj .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-JPhGR2zGtQxHILsj .noteText,#mermaid-svg-JPhGR2zGtQxHILsj .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-JPhGR2zGtQxHILsj .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-JPhGR2zGtQxHILsj .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-JPhGR2zGtQxHILsj .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-JPhGR2zGtQxHILsj .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .section{stroke:none;opacity:0.2}#mermaid-svg-JPhGR2zGtQxHILsj .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-JPhGR2zGtQxHILsj .section2{fill:#fff400}#mermaid-svg-JPhGR2zGtQxHILsj .section1,#mermaid-svg-JPhGR2zGtQxHILsj .section3{fill:#fff;opacity:0.2}#mermaid-svg-JPhGR2zGtQxHILsj .sectionTitle0{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .sectionTitle1{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .sectionTitle2{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .sectionTitle3{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-JPhGR2zGtQxHILsj .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .grid path{stroke-width:0}#mermaid-svg-JPhGR2zGtQxHILsj .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-JPhGR2zGtQxHILsj .task{stroke-width:2}#mermaid-svg-JPhGR2zGtQxHILsj .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .taskText:not([font-size]){font-size:11px}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-JPhGR2zGtQxHILsj .task.clickable{cursor:pointer}#mermaid-svg-JPhGR2zGtQxHILsj .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-JPhGR2zGtQxHILsj .taskText0,#mermaid-svg-JPhGR2zGtQxHILsj .taskText1,#mermaid-svg-JPhGR2zGtQxHILsj .taskText2,#mermaid-svg-JPhGR2zGtQxHILsj .taskText3{fill:#fff}#mermaid-svg-JPhGR2zGtQxHILsj .task0,#mermaid-svg-JPhGR2zGtQxHILsj .task1,#mermaid-svg-JPhGR2zGtQxHILsj .task2,#mermaid-svg-JPhGR2zGtQxHILsj .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutside0,#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutside2{fill:#000}#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutside1,#mermaid-svg-JPhGR2zGtQxHILsj .taskTextOutside3{fill:#000}#mermaid-svg-JPhGR2zGtQxHILsj .active0,#mermaid-svg-JPhGR2zGtQxHILsj .active1,#mermaid-svg-JPhGR2zGtQxHILsj .active2,#mermaid-svg-JPhGR2zGtQxHILsj .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-JPhGR2zGtQxHILsj .activeText0,#mermaid-svg-JPhGR2zGtQxHILsj .activeText1,#mermaid-svg-JPhGR2zGtQxHILsj .activeText2,#mermaid-svg-JPhGR2zGtQxHILsj .activeText3{fill:#000 !important}#mermaid-svg-JPhGR2zGtQxHILsj .done0,#mermaid-svg-JPhGR2zGtQxHILsj .done1,#mermaid-svg-JPhGR2zGtQxHILsj .done2,#mermaid-svg-JPhGR2zGtQxHILsj .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-JPhGR2zGtQxHILsj .doneText0,#mermaid-svg-JPhGR2zGtQxHILsj .doneText1,#mermaid-svg-JPhGR2zGtQxHILsj .doneText2,#mermaid-svg-JPhGR2zGtQxHILsj .doneText3{fill:#000 !important}#mermaid-svg-JPhGR2zGtQxHILsj .crit0,#mermaid-svg-JPhGR2zGtQxHILsj .crit1,#mermaid-svg-JPhGR2zGtQxHILsj .crit2,#mermaid-svg-JPhGR2zGtQxHILsj .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-JPhGR2zGtQxHILsj .activeCrit0,#mermaid-svg-JPhGR2zGtQxHILsj .activeCrit1,#mermaid-svg-JPhGR2zGtQxHILsj .activeCrit2,#mermaid-svg-JPhGR2zGtQxHILsj .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-JPhGR2zGtQxHILsj .doneCrit0,#mermaid-svg-JPhGR2zGtQxHILsj .doneCrit1,#mermaid-svg-JPhGR2zGtQxHILsj .doneCrit2,#mermaid-svg-JPhGR2zGtQxHILsj .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-JPhGR2zGtQxHILsj .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-JPhGR2zGtQxHILsj .milestoneText{font-style:italic}#mermaid-svg-JPhGR2zGtQxHILsj .doneCritText0,#mermaid-svg-JPhGR2zGtQxHILsj .doneCritText1,#mermaid-svg-JPhGR2zGtQxHILsj .doneCritText2,#mermaid-svg-JPhGR2zGtQxHILsj .doneCritText3{fill:#000 !important}#mermaid-svg-JPhGR2zGtQxHILsj .activeCritText0,#mermaid-svg-JPhGR2zGtQxHILsj .activeCritText1,#mermaid-svg-JPhGR2zGtQxHILsj .activeCritText2,#mermaid-svg-JPhGR2zGtQxHILsj .activeCritText3{fill:#000 !important}#mermaid-svg-JPhGR2zGtQxHILsj .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-JPhGR2zGtQxHILsj g.classGroup text .title{font-weight:bolder}#mermaid-svg-JPhGR2zGtQxHILsj g.clickable{cursor:pointer}#mermaid-svg-JPhGR2zGtQxHILsj g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-JPhGR2zGtQxHILsj g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-JPhGR2zGtQxHILsj .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-JPhGR2zGtQxHILsj .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-JPhGR2zGtQxHILsj .dashed-line{stroke-dasharray:3}#mermaid-svg-JPhGR2zGtQxHILsj #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj .commit-id,#mermaid-svg-JPhGR2zGtQxHILsj .commit-msg,#mermaid-svg-JPhGR2zGtQxHILsj .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-JPhGR2zGtQxHILsj g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-JPhGR2zGtQxHILsj g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-JPhGR2zGtQxHILsj g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-JPhGR2zGtQxHILsj .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-JPhGR2zGtQxHILsj .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-JPhGR2zGtQxHILsj .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-JPhGR2zGtQxHILsj .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-JPhGR2zGtQxHILsj .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-JPhGR2zGtQxHILsj .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-JPhGR2zGtQxHILsj .edgeLabel text{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-JPhGR2zGtQxHILsj .node circle.state-start{fill:black;stroke:black}#mermaid-svg-JPhGR2zGtQxHILsj .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-JPhGR2zGtQxHILsj #statediagram-barbEnd{fill:#9370db}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-state .divider{stroke:#9370db}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-JPhGR2zGtQxHILsj .note-edge{stroke-dasharray:5}#mermaid-svg-JPhGR2zGtQxHILsj .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-JPhGR2zGtQxHILsj .error-icon{fill:#522}#mermaid-svg-JPhGR2zGtQxHILsj .error-text{fill:#522;stroke:#522}#mermaid-svg-JPhGR2zGtQxHILsj .edge-thickness-normal{stroke-width:2px}#mermaid-svg-JPhGR2zGtQxHILsj .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-JPhGR2zGtQxHILsj .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-JPhGR2zGtQxHILsj .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-JPhGR2zGtQxHILsj .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-JPhGR2zGtQxHILsj .marker{fill:#333}#mermaid-svg-JPhGR2zGtQxHILsj .marker.cross{stroke:#333}
:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}
#mermaid-svg-JPhGR2zGtQxHILsj {
color: rgba(0, 0, 0, 0.75);
font: ;
}
是
否
是
否
是
否
是
否
是
开始
I_a[1:0]==I_a[1:0] ?
CO[0] = 0
CO[0] = I_a[1:0] > I_b[1:0] ? 1 : 0
I_a[3:2]==I_a[3:2] ?
CO[1] = CO[0]
CO[1] = I_a[3:2] > I_b[3:2] ? 1 : 0
I_a[3:2]==I_a[5:4] ?
CO[2] = CO[1]
CO[2] = I_a[5:4] > I_b[5:4] ? 1 : 0
I_a[6:5]==I_a[6:5] ?
CO[3] = CO[2]
CO[3] = I_a[6:5] > I_b[6:5] ? 1 : 0
CO[3] = 1 ?
I_a > I_b
结束