How to partition a top module into 2 sub-module using submod command? - yosys

I am having problem partitioning my top module using using submod command.
I have a simple counter (I have a behavioral code for a 4bit counter). with the following cells in it:
yosys> select -list
counter
counter/$procmux$4_Y
counter/$add$counter.v:10$2_Y
counter/$0\count[3:0]
counter/count
counter/en
counter/rst
counter/clk
counter/$procdff$9
counter/$procmux$7
counter/$procmux$4
counter/$add$counter.v:10$2
Now I want to put the following cells into a submodule:
counter/$procdff$9
counter/$procmux$7
I do not know how to use select, setattr, submod to do so. Any help is greatly appreciated.
Thank you
verilog code for my counter:
module module counter (clk, rst, en, count);
input clk, rst, en;
output reg [3:0] count;
always #(posedge clk)
if (rst)
count <= 4'd0;
else if (en)
count <= count + 4'd1;
endmodule

I figured it out:
first I select the cells, then put them into the partition that I want:
yosys> select counter/$procmux$4
yosys*> select -add counter/$procmux$7
yosys*> select -add counter/$add$counter.v:10$2
yosys*> submod -name sub_2
yosys> select counter/$procmux$4_Y
yosys*> select -add counter/$add$counter.v:10$2_Y
yosys*> select -add counter/$0\count[3:0]
yosys*> select -add counter/count
yosys*> select -add counter/$procdff$9
submod -name sub_1
please let me know if there is a better way.
Thank you

Related

Cause a job failure with sql for data checks

I would like to action some data checks following data imports into my system, im checking that all of my key locations have inventory imported for them and if they dont i would like the job to fail (I then have reporting/alerts set up when any jobs fail)
Ive had a search around and tried a number of options - The lines commented out are what i have tried but when i set INV_CHECK variable above the count level of one of my locations the job still completed succesfully. If i run in TOAD then it will fail and present an error which is what i had wanted the job to do.
Declare valid_loc NUMBER;
Inv_check NUMBER;
no_inv number;
BEGIN
select param_value into Inv_check from
scpomgr.udt_systemparam where param_name = 'INV_CHECK';
select count (*) into valid_loc from
(select distinct loc
from scpomgr.inventory
where loc in ('GB01', 'FR01', 'DE01', 'IT01', 'ES01', 'IE01', 'CN01', 'JP01', 'AU01', 'US01')
having count (*) > Inv_check
group by loc);
if valid_loc
<10 THEN
--raise_application_error(-20001,'Likely Missing Inv Records');
--raiseerror('fail',16,1);
--select 1/0 into no_inv from dual;
--THROW (51000, 'Process Is Not Finished', 1);
END IF;
END;
EXIT
Can anyone point me in the right direction of what ive missed / misunderstood?
Ive added an action into the If statement so i know its running the part after the 'Then' and if i run in TOAD it gives me an error, if i do it via 'PUTTY' which is what i use to run batch processes then it comes out as 'COMPLETE' and doesnt show any sort of failure.
So after a number of trial and error i found the below code gives me the desired result, to cause my process table / putty runs to display failed i needed to use pkg_job.fatel_error and with that i could pass an error message/code.
Declare
valid_loc NUMBER;
Inv_check NUMBER;
BEGIN
select param_value into Inv_check from
scpomgr.udt_systemparam where param_name = 'INV_CHECK';
select count (*) into valid_loc from
(select distinct loc
from scpomgr.inventory
where loc in ('GB01', 'FR01', 'DE01', 'IT01', 'ES01', 'IE01', 'CN01', 'JP01', 'AU01', 'US01')
group by loc
having count (*) > Inv_check
);
if valid_loc < 10 THEN
pkg_job.fatal_error('Likely Missing Inv Records',-20001);
END IF;
END;
/
EXIT
Hope this helps others or gives ideas of what to try.

How to write consecutive case statements?

I got an assignment to make a 4-bit booth multiplier with unsigned inputs in Verilog.
I've only used verilog a few times before this, so I'm not too familiar in writing case statements in it.
module booth(ina,inb,out);
input [3:0] ina, inb;
output[7:0] out;
reg[2:0] p1,p2;
reg[5:0] temp1, temp2;
assign p1={inb[2],inb[1],0};
assign p2={inb[3],inb[2],inb[1]};
always #(*)
begin
out = 8'b00000000;
case(p1)
3'b000: temp1=0;
3'b010: temp1=ina;
3'b100:temp1=-2 * ina;
3'b110:temp1= -ina;
endcase
end
begin
case(p2)
3'b000,3'b111: temp2=0;
3'b001,3'b010: temp2=ina;
3'b011:temp2=2 * ina;
3'b100:temp2=-2 * ina;
3'b101,3'b110:temp2= -ina;
endcase
temp2 = temp2<<2;
end
assign out=temp1+temp2;
endmodule
How am I supposed to write two case statements in a row?
I get a syntax error:
syntax error near text: "begin"; expecting "endmodule". Check for and fix any syntax errors that appear immediately before or at the specified keyword.
There are several compile errors.
Your error message probably refers to the 2 consecutive begin/end blocks after your always statement. One way to fix this is to add a 2nd always statement. It is a good idea to separate the temp1 and temp2 logic this way.
I also get an error for p1 because you make a continuous assignment to it with an assign statement. You should declare the signal as a wire, not a reg. Change:
reg [2:0] p1,p2;
to:
wire [2:0] p1,p2;
Another problem is that you make multiple assignments to the out signal. I think you probably want to remove it from the always block.
Lastly, you need to use a sized constant for 0 in the p1 statement. Change:
assign p1={inb[2],inb[1],0};
to:
assign p1={inb[2],inb[1],1'b0};
This code compiles cleanly for me:
module booth (ina, inb, out);
input [3:0] ina, inb;
output [7:0] out;
wire [2:0] p1,p2;
reg [5:0] temp1, temp2;
assign p1 = {inb[2], inb[1], 1'b0};
assign p2 = {inb[3], inb[2], inb[1]};
always #(*) begin
case (p1)
3'b000: temp1 = 0;
3'b010: temp1 = ina;
3'b100: temp1 = -2 * ina;
3'b110: temp1 = -ina;
endcase
end
always #(*) begin
case(p2)
3'b000,3'b111: temp2 = 0;
3'b001,3'b010: temp2 = ina;
3'b011: temp2 = 2 * ina;
3'b100: temp2 = -2 * ina;
3'b101,3'b110: temp2 = -ina;
endcase
temp2 = temp2<<2;
end
assign out = temp1+temp2;
endmodule

Refer to a macrolist which name depends on a variable

%let list_2=‘a’,’b’,’c’;
PROC SQL;
CREATE TABLE test AS
SELECT
Bin, /*value is a*/
Rank, /*value is 2*/
CASE
WHEN Bin IN (&list_Rank.) /*list_2=‘a’,’b’,’c’*/
THEN 1
ELSE 0
END AS test
FROM Source
;
QUIT;
I am looking for a way to use the value of column Rank in the reference to the macrovariable list_2.
As #John commented, you can use SYMGET function to use data to look up the value of a macro variable during run-time. I don't think you can use the IN operator for what you want, because it expects a list of character strings, while SYMGET will return a single string. Below I took the quotes out of the &LIST_2 (just to make it easier to work with), and used FINDW to do the work of IN. I think this is along the lines of what you're describing:
%let list_2=a,b,c;
%let list_3=d,e,f ;
data have ;
input bin $1. rank ;
cards ;
a 2
a 3
e 2
e 3
;
run ;
proc sql ;
select
bin
,rank
,case when findw(symget(cats("list_",rank))
,bin
) then 1
else 0
end as test
,symgetc(cats("list_",rank)) as symgetc /*debugging*/
from have ;
quit ;
You could add another CASE statement. Actually since it is SAS code you could eliminate the current CASE statement and just use the result of the IN operation which will be 0 (false) or 1 (true).
%let list_1='a','b','c';
%let list_2='d','e','f';
%let nlists=2;
PROC SQL;
CREATE TABLE test AS
SELECT
Bin /*value is a*/
, Rank /*value is 2*/
, case
when (rank=1) then bin in (&list_1)
when (rank=2) then bin in (&list_2)
else 0
end as test
FROM Source
;
QUIT;
If you are running inside a macro you could use a %do loop to generate the when clauses.
%do i=1 %to &nlists ;
when (rank=&i) then bin in (&&list_&i)
%end;
If you are not in a macro then create a macro to run the %do loop and call it at the appropriate place.

File input for select statement in shell scipt

I have a text file which has inputs for select statement.
sqlplus -s $USERNAME/$PASSWORD#$HOST<< EOF
spool $DIRECTORY/UPDATE.xls
select acc,cr,dr from count where acc in $DIRECTORY/acc.txt;
spool off;
exit
EOF
Please let me know how to use the text file as input at highlighted part.
You can just use the back tics for that in combination with the cat command. So
select acc,cr,dr from count where acc in `cat $DIRECTORY/acc.txt`;

PROC compiler fails for connect with prior in case using 'NOCYCLE'

I am very new to PROC and I was compiling following query in .pc file,
`
SELECT * FROM CUST
WHERE CUSTOMER_ID = :sqli_customer_id
START WITH SUBSCRIBER_NO = :sqli_subscriber_no
CONNECT BY NOCYCLE PRIOR PRV_CTN = SUBSCRIBER_NO
ORDER BY ROWNUM DESC
`
following query fails to compile in PROC complier
but when I remove the NOCYCLE from query, file gets successfully compiled.
I get following error with NOCYCLE:
PCC-S-02201, Encountered the symbol "PRIOR" when expecting one of the following:
= ( * < > + - / . # ^= | != <= >= <> at, not, between, in, is, like, day, hour, minute, month, second, year,
The symbol "*" was substituted for "PRIOR" to continue.
`
Any suggestion will be helpful.
Thanks,
Nitin T.