Giter VIP home page Giter VIP logo

lsv-pa's Introduction

LSV-PA, Fall 2023

This is a repository to host programming assignments of the course Logic Synthesis and Verification at National Taiwan University. It is forked from the repository ABC of UC Berkeley.

Submission Workflow

We will follow a common git feature branch workflow for submission. All enrolled students will have their own branches named by their students' ID numbers. You are asked to fork this repository and develop your program on the forked repository. After finishing your programming assignments, the assignments must be submitted via a pull request to a student's own branch (please do not modify the master branch). If you cannot find your own branch, please contact the TA. If you don't know how to create a pull request, please read through this document.

To avoid plagiarism ...

Please note that your fork of this public repository will also be public, which means that if you push your code to the fork, it is visible to everyone. In case you want to prevent other students from copying your solution, an easy way is to push and create a pull request at the last moment before the deadline.

Another complicated way is to create a private repository to develop your solutions, pull your code to the public fork after an assignment is finished, and create a pull request via the public fork. The benefit of this method is that you can push your code during the development and keep it private. The drawback is again you need to create a pull request close to the deadline, as PRs are visible to everyone. The detailed steps are documented here.

Participants

We recommend students to register their student IDs and GitHub accounts in this table.

Assignments

PA1: Functional simulation

Submission deadline:

  • Exercises 1-3: 2023/09/17 23:59
  • Exercises 4: 2023/10/01 23:59

Contact

TA: Tian-Fu Chen ([email protected])

For questions, you are encouraged to open an issue. As other students might have the same questions, discussing in an issue will benefit everyone. Note that you can set labels, e.g., PA0, PA1, etc, to classify your questions.

lsv-pa's People

Contributors

2a-github avatar alanminko avatar boschmitt avatar eddiehung avatar gordon0813 avatar hankshyu avatar hriener avatar hzeller avatar j09188 avatar jamesjer avatar jhrjiang avatar lauren-yrluo avatar lindream88 avatar melody16483 avatar melody16843 avatar msoeken avatar myskyko avatar niklaseen avatar quantamhd avatar r11943187 avatar rjkly98 avatar shao-wei avatar spongebobaa16 avatar sterin avatar str367 avatar surviveric avatar tfchen01 avatar tp6fu6m3 avatar wjrforcyber avatar yshotw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lsv-pa's Issues

A reference program and a grading script

I just pushed a reference program for PA1 and a grading script that will be used to grade your solutions.

The reference program is compiled under Ubuntu 20.04 and libreadline8.
It has to be zipped otherwise it exceeds the file size limit (100 MB) of GitHub.

The grading script compares the outputs produced by the reference program and a student's program.
The usage of the script is:

Usage: ./lsv/admin/grade-submissions.sh <ALL|branch-name>
ALL: grade ALL students
branch-name: the branch to grade, e.g., d04943019

If your code is in master, just type ./lsv/admin/grade-submissions.sh master

The comparison is done by diff -uwiB <ref.txt> <out.txt>, which ignores all white space, blank lines, and case differences.
We will use 40 test cases from the EPFL benchmark suite at tag v2020.1.
Two points will be given if the return code of diff equals 0.
For the script to find the test cases, you have to create a symbolic link to the EPFL benchmark suite as described here.

You are encouraged to test your solution, and please speak up if there is any problem.

PA1 reference answers and grading script

I added a grading script that will be used to grade your solutions.

The usage of the script is:

Usage: ./lsv_fall_2021/admin/grade-submissions.sh <ALL|branch-name>
ALL: grade ALL students
branch-name: the branch to grade, e.g., d04943019

If your code is in <branch>, just type ./lsv_fall_2021/admin/grade-submissions.sh <branch>.
Your branch has been synchronized with the master branch. Therefore, to obtain the above updates is to synchronize your local branch with the upstream branch (i.e., the branch with your student ID number). Please refer to issue #338 for syncing your local branch.

For part 1, 5 points will be given if your BLIF is equivalent with the reference BLIF, where the equivalence is decided by ABC command dsec -n.

For part 3, the grading script compares the reference answers and outputs of a student's program. The comparison is done by diff -uwiB <ref.txt> <out.txt>, which ignores all white space, blank lines, and case differences.
We will use 20 test cases from the EPFL benchmark suite.
4 points will be given if the return code of diff equals 0 for each test case.
For the script to find the test cases, you have to create a symbolic link to the EPFL benchmark suite as described here.

You are encouraged to test your solution, and please speak up if there is any problem with the grading script or reference answers.

Run Well on macOS but get segmentation fault on Linux

As the title, my program not even prints ("###\n") out which I add in the void init(Abc_Frame_t* pAbc) {}.
I think that it's a big issue because TA might test it on Linux platform.
But I have no idea what's going on.
Thanks.

CI updated for PA2

A sanity test for PA2, which checks the output of your program over EPFL test case random_control/ctrl.aig against its reference answer, has been added to CI.
This check intends to help students to discover easy-to-fix errors (e.g., sorting) when they send PRs.

How to obtain an AIG circuit (Aig_Man_t) from a network (Abc_Ntk_t)

助教您好

我在第一個問題就卡關了QQ
面對像abc這樣龐大的project,trace code時要如何有效率地去找到某個特定的API呢?
以我現在面對的問題為例,我只能猜應該有一個function是把Abc_Ntk_t當作input,Aig_Man_t當作output,但是如果用grep針對這兩個關鍵字下去找,會找到一堆無關緊要的東西。而我去看了定義Abc_Ntk_t跟Aig_Man_t這兩個struct的檔案,找到的也都是我能用它來做什麼,而不是我該如何得到它。想知道未來面對類似的問題,該如何有效率地去找到某個特定的API。

謝謝解惑

How to prevent plagiarism given that PRs are visible to everyone?

After a student submits a PR, his or her solution is visible to everyone.
How could we prevent plagiarism under this scenario?

Some possibilities are listed below:

The first option, as indicated by its name, is designed for educational purposes.
However, to avoid confusion for students, I am hesitating to switch to it.

The second option seems too complicated, and we should not abuse the functionality.
We also want to have the PRs become public after the deadline, so that students can learn from each other's code.

The simplest solution I can come up with is to ask students to submit within an allocated period of time.
For example, if the deadline is at 23:59, we can ask students to submit after 20:00.
This of course increases inconvenience of students, but compared to the above alternatives, the additional cost should be the least.

@jhrjiang , @isuis3322 : could you please comment or suggest other solutions?

PA2 輸出疑問

助教您好
假如對於output[0]來說,input[1]和input[2]並不會影響output[0] (不在support之中)
那麼input[1]和input[2]自然就會symmetric,請問需要輸出這一組嗎?

lsv_sym_all 0
1 2

謝謝!

得到single output的cnf

助教您好

目前我知道如何透過Abc_Ntk_t得到Aig_Man_t,並由Aig_Man_t得到Cnf_Dat_t
但是上述的Cnf_Dat_t是把所有的clause全部混在一起(變成一個大的muti-output circuit),而PA2應該是要針對每個PO個別處理(拆成許多小的single output circuit),因此我必須要得到single output的Cnf

由Abc_Ntk_t可以得到每一個PO node(type是Abc_Obj_t)
由Aig_Man_t也可以得到每一個PO aig node(type是Aig_Obj_t)
但是似乎沒有API可以從上述的PO Abc_Obj_t或Aig_Obj_t變成Cnf_Dat_t?
如果想得到single output的cnf,是不是要參考如Cnf_Derive這樣的function,自己寫一個類似的function,針對每個PO node DFS轉成CNF呢?

因為感覺是個不小的工程,因此想先確認一下我的想法是不是有錯
謝謝助教解惑

unate在「用0表示的SOP」的定義

助教您好

我想確認一下unate在「用0表示的SOP」的定義
例如某個2-variable的node的SOP寫成下面這一行
00 0

表示他其實等價於
01 1
10 1
11 1

也就是這兩個variable都是binate對嗎?
謝謝

Rearrange the directory structure

I would like to suggest rearranging the current directory structure, in order to avoid duplication and confusion.

I propose to have only one lsv folder, instead of having both lsv from last year and lsv_fall_2021 for this year.
We could create a folder named archive under lsv and put the old PA folders inside it.
The admin folder would remain the same, except for an updated student list participants-id.csv.
The example folder also stays there, because the Wiki pages link to those files.

@Luo-Yun-Rong What do you think?

PA1 problem 2

助教您好

請問PA1 第二題是要我們繳交一份文件檔
(a)用文字說明這四個指令差在哪裡
(b)把AIG轉SOP的指令依序列出來
就好了嗎?

其中(a)有提到要用four-bit adder當作例子,所以我們有需要繳交什麼程式跑出來的結果嗎?(print_stats或show生成的圖檔之類的)

謝謝解惑

能否在abc project中新增檔案與資料夾

助教您好

針對PA1第三題,我們是不是只能將code寫在lsvCmd.cpp裡面阿?

因為我現在的做法是,在ext-lsv資料夾中額外新增了一個檔案叫print_sopunate.cpp,並將code實作在這個檔案內,當然同時也改寫了module.make所以整個abc在make之後能夠順利運作。

但是當我打git status後發現,他只有顯示我modified module.make,而沒有我新創的print_sopunate.cpp檔案,其他如add、commit、push也都找不到我新創的這個file。
我不確定這是不是因為當初這個project是從助教那邊fork過來的,所以我不能新增額外的檔案跟資料夾,而只能在現有的檔案做編輯。還是其實我只是應該調整什麼設定才能讓git抓到我新增的檔案呢?

謝謝解惑

What is four-number serial adder?

I am confused about "four-number serial adder".

Can TA give a more specific definition about it?
i.e. Can TA be more specific on inputs/outputs relation, perhaps give us some example?

"show" Command Doesn't Work Well on Mac with XQuartz(gv)

I'm working on a MacBook Pro. According to this advice, XQuartz(gv) should be used instead of GSView on a Mac.
截圖 2023-09-12 下午3 11 03

However, when I run the "show" command in the abc program, I get the following warning messages:
截圖 2023-09-12 下午3 30 32

If I first set export LANG=C and then run the "show" command in the abc program, an XQuartz(gv) window pops up but it's empty.
截圖 2023-09-12 下午3 06 27

How can I fix it? Thanks a lot.

Reference:
advice from
http://geodesy.gl.ntu.edu.tw/index.files/%E6%95%99%E5%AD%B8%E8%B3%87%E6%BA%90/%E5%9C%B0%E7%90%83%E7%89%A9%E7%90%86%E8%B3%87%E6%96%99%E8%99%95%E7%90%86%20(GMT)/Powerpoint_install_Introduction/gmt600_2020_install.pdf

Bad practices observed in the submission of PA1

Here are some bad practices I found during the submission of PA1:

  • DO NOT commit *.o or *.d files: a general practice is not to commit auto-generated files
  • DO NOT commit pa1-ref and other grading-related files: it is technically okay, but will cause problems for the grading script. These files are also auto-generated. Please don't commit them.
  • DO NOT create a pull request without syncing with the remote branch: to avoid merge conflicts, you have to first sync your local branch with the remote branch (in our case: NOT master but the branch with your student ID)

Feedback and questions

Dear Students,

Now that the submission period of parts 1 and 2 for PA1 is over,
I would like to invite you to give your feedback or ask questions about the submission workflow.
Please speak up. Your comments are cordially welcome.
Depending on your response, we may allocate an additional hands-on session to help you with the PAs.

Grading scripts issues

The grading script evokes the command timeout. For Mac users, please run the following in your terminal to install this command.

brew install coreutils

If you cannot execute the reference program (it reports: ./abc.linux Permission denied). Please run the following:

chmod 777 ./abc.linux

Lockdown CI improvement

  1. Automatically close all PRs to master
  2. If a PR is open during the submission period, one can still push new commits even if lockdown is enabled.

PA1 part3 關於benchmark

助教您好:
想確認一下,benchmark中是只會拿.blif檔來測嗎?.aig .v .vhd檔應該是不會用來作為測資對嗎?
麻煩助教解惑! 感謝您。

pull request can't automatically merge

助教好:我在 commit 之前我有先進行fetch upstream, 然而今天的 pull request 一直有 merge conflict, 請問助教能幫我看一下哪邊出錯嗎?謝謝。

Please sync your fork before you send PR to <your-student-id> branch

You have to make sure your PR does not have conflicts with <your-student-id> branch. Otherwise it will not be merged.

Before sending a PR, you may need to sync your fork to avoid conflicts. That is, suppose you are on the branch that you develop your PAs. You have to run the followings.

$ git remote add upstream [email protected]:NTU-ALComLab/LSV-PA.git
$ git fetch upstream
$ git merge upstream/<your-student-id> 
$ git push

Note that for PA1 & PA2, you have to send PR to <your-student-id> branch.
DO NOT send PR to master.
Thanks.

show command not working

I installed graphviz and gv package but still got an error when using show command
Error message:
gv: Unable to open the display.

Are there additional packages I need to install?

PA1-1

助教好,

想請問"show"和"show bdd"的圖檔,
要交截圖呢?還是.ps檔?或是可以把截圖全部放在一個pdf中交?
謝謝。

[指令問題] show_bdd -g

PA1 Part 1 (b)的 7. visualize the BDD (command “show bdd -g”; note that “show bdd” only
shows the first PO; option “-g” can be applied to show all POs)

但實際操作卻告訴我它找不到-g的option
abc 03> show_bdd -g
show_bdd: unknown option g

請問這是我版本問題 還是有什麼新的command沒有新增上去,使得產生不出有所有PO的ps檔.

Nodes with zero fanins

助教您好,

我測試benchmark時,用範例command: "lsv_print_nodes" 時會遇到這種node
Object Id = 61, name = n61 The SOP of this node: 1
看起來應該是constant 1, 請問對於這種node我們應該怎麼處理呢?
請問是比照absent-variable 的處理方式嗎?這樣這個node的fanin就是所有PI嗎?

謝謝助教!

The show command does not display the circuit

Hi,
I was following the demo on Wiki page, where I tried reading inlsv/example/full_adder.blif, and used show to draw the circuit. However, the command only rendered an blank gui, as shown in the image below:

截圖 2021-10-01 下午5 07 53

ABC also threw the following warning message, which suggests that it may be a font issue. However, I can't seem to find how to resolve the issue.

abc 02> Warning: locale not supported by Xlib, locale set to C
Warning: X locale modifiers not supported, using default
Warning: Cannot convert string "-efont-biwidth-medium-r-normal--16-*-*-*-*-*-iso10646-1,-gnu-unifont-medium-r-normal--16-*-*-*-*-*-iso10646-1,-adobe-helvetica-medium-r-normal--14-*-*-*-*-*-*-*,-jis-fixed-medium-r-*--16-*-*-*-*-*-jisx0208.1983-0,-*-*-medium-r-*--16-*-*-*-*-*-*-*,*" to type FontSet
Warning: Unable to load any usable fontset
Warning: Unable to load any usable fontset

I am on macOS X 11.4, and have installed both GraphViz and gv with brew install graphviz and brew install johnhcc/gs-x11/gv, respectively.

Thanks for the help in advance.

CNF的Var 與Abc_Obj_t 的 ID之間的關聯

助教您好

以下是我目前的理解不知道有沒有誤:

在Abc_Ntk_t中,每個Abc_Obj_t都有自己的ID以及name
以1-bit adder為例,三個input的(ID, NAME)分別是(1,a)(2,b)(3,c-in)
當我把Abc_Ntk_t變成Aig,並進一步變成Cnf_Dat_t時
其Var與ID之間的mapping應該是記錄在Cnf_Dat_t->pVarNums中
其中pVarNums的index代表原先的ID,其值代表他所對應的Var
以1-bit adder為例,Cnf_Dat_t->pVarNums[1] = 3,表示第一個input (1,a) 對應到的var是3(從3開始應該是與var創建的順序有關)

我的問題是:
1.從Abc_Obj_t ID到Var可以直接查pVarNum,但似乎卻沒辦法很快的反向搜索?
當我拿到一個var想知道他對應到的Abc_Obj_t ID,這個mapping我們是不是要自己實作?
Wiki Key Questions的第三點說要rename variable指的是這件事嗎?(創建一個array去紀錄Var to ID 的mapping之類的)

2.在1-bit adder中,Cnf_Dat_t->pVarNums[0] = 6。
如果我上述的理解沒有錯的話,表示var 6代表的是Abc_Obj_t的constant node(ID = 0)
然而我把1-bit adder 的c-out的cnf印出來長這樣

full_adder_c-out
2 3 5
2 4 5
2 3 4
-2 -3 -4
-2 -4 -5
-2 -3 -5
6
1 2
-1 -2

其中var[3,4,5]分別對應到input[a, b, c-in]
那var 1、 2是什麼呢?(在pVarNums沒有紀錄)
還有var 6如果是constant node的話
我看不太懂為什麼1-bit adder 的c-out的cnf是長這樣

謝謝助教解惑

Question regarding Input variable order

Hi, if the variable order in the .blif file is defined as:
.inputs a b c
This would mean the 0th PI stored in ABC is a, 1th PI is b, 2nd PI is c, if I'm not mistaken.

The commands in this assignment would take an input sequence, for example 100.
What order should we parse the input? Should it be in
100 => a=1, b=0, c=0, to follow the ordering of the input,
or
100 => a=0, b=0, c=1, since 1 is technically the 2nd element in the array i[3] = {1,0,0}?
Thank you.

Some questions about Pa1 problem4

  1. Is it allowed to call the function 'Cudd_Eval'?
  2. Is there any specification on the input pattern? Like the function y=a+b+c, is the input 001 meaning a,b,c or b,a,c or other possible permutations, like the variable ordering in the BDD structure ?

what kind of representation should we expect in PA1 part 3?

There are different ways to represent Boolean functions in ABC. ex: aig, strash, bdd, ...

In PA1_README, "Write a procedure in ABC that find maximum single-fanout cones (MSFCs) that covers all nodes (excluding PIs and POs) of a given AIG."
Since the picture in PA1_README can only be seen after "strash" command, does it mean that the network would be executed by "strash" before being executed by "lsv_print_msfc"?
圖片

i.e. when we try to test our procedure ourselves by a BLIF file, should we first "read", then "strash" to make it AIG, and then "lsv_print_msfc"?

Unateness of an absent variable in an SOP

Consider the following node:

.names a b c d f
111- 1

Is variable d positive unate, negative unate, or binate?
Please think about this question and handle this situation in your solutions.

problem2 (b)

助教您好

第二題的(b)就我目前的理解是,在strash之後ABC會將network存成structurally hashed AIG的形式。此時如果要恢復成SOP,應該只需要下"logic"這個指令即可。因此不懂為何題目敘述是要我們列出 a sequence of command(我的理解只需要"logic"這一個command)。

我自己推測的幾個可能是:

  1. 題目要求從讀進aig檔開始
    因此是read file.aig -> logic ->done!
    2.題目要求不只是要SOP,而是要在被strash化簡之前的function node的SOP
    關於這點我有查到一個指令是"renode",根據ABC官網的說法它可以recreating SOP logic network from the AIG 。
    但是我拿4-bit_Adder實驗的結果發現,strash之後再renode並不能完全恢復成strash前的模樣。
    而且如果不斷的重複strash->renode->strash->renode->strash-> ...,每次出來的結果也不一樣。
    因此不知道該如何理解renode這個指令。

謝謝解惑

gv: unable to open the display

Hi,

I was also following the demo on Wiki page and using "show" command, but failed. Here are some images:
gv1

I was running demo on Ubuntu, and had already installed the required two packages.

Sorry to bother you and thanks in advance.

PA2 reference program and grading script

I added a grading script that will be used to grade your solutions.

The usage of the script is:

Usage: ./lsv_fall_2021/admin/grade-submissions.sh <ALL|branch-name> <mac|linux>
ALL: grade ALL students
branch-name: the branch to grade, e.g., d04943019

If your code is in <branch> and your system is linux, just type

./lsv_fall_2021/admin/grade-submissions.sh <branch> linux

Similarly, if your code is in <branch> and your system is macOs, just type

./lsv_fall_2021/admin/grade-submissions.sh <branch> mac

Your branch has been synchronized with the master branch. Therefore, to obtain the above updates is to synchronize your local branch with the upstream branch (i.e., the branch with your student ID number). Please refer to issue #338 for syncing your local branch.

The reference programs abc.mac and abc.linux implemented the command lsv_or_bidec. You can refer to it or compare the runtime between your program and reference program. We set the runtime limit to be 60s for each case. Your answer will be evaluated by the checker command lsv_pa2_checker. It reports Pass! if your result of a test case is correct.

We will use 9 test cases from the EPFL benchmark suite.
11 points will be given for each success case.
For the script to find the test cases, you have to create a symbolic link to the EPFL benchmark suite as described here.

You are encouraged to test your solution, and please speak up if there is any problem with the grading script or reference programs.

ABC cannot recognize pattern ".clock" in BLIF files.

You may notice that ABC reports: Skipping line... upon reading .clock in BLIF files.
You can resort to another way of expressing a latch, where controlling clock is not specified, e.g.

.latch latch_in latch_out 0

It is assumed that the latch is actually controlled by a single global clock.
It is fine that show does not visualize the clock.

Failed assertions on reading in *.blif files with latches

Hi there,
When trying to read *.blif files with latches, my ABC crashes and throws the following error message:

Assertion failed: (!Abc_ObjIsNet(pObj) || !Abc_ObjFaninNum(pObj)), function Abc_ObjAddFanin, file src/base/abc/abcFanio.c, line 92.

I am using one of the example from this manual to BLIF,

.model latch_ex
.inputs in       # a very simple sequential circuit
.outputs out
.latch out in 0
.names in out
0 1
.end

which should be a fairly minimalistic example. I have tried pinning down the problem with lldb, but it couldn't read the object pointed by pObj.

// message from running the lldb debugger
error: <user expression 8>:1:2: use of undeclared identifier 'pObj'
*pObj

I also tried searching, with no success so far, for a newer version of manual, or possible undocumented constraints on the *.blif inputs.

I am using the version of ABC from this repo, but, as a side note, the problem persists on the version from berkeley-abc, too.
The OS is macOS X 11.4.

Thanks a lot.

sat_solver_add_buffer_enable() enabling variable

想請問助教sat_solver_add_buffer_enable() 之中enabling variable的功能。
我的理解是enbling variable ==1的時候,iVarA 和iVarB 會被控制成equivalent。
因此在這次作業之中,所有的enbling variable 都應該被設為1。
想請問助教我的理解是否錯誤?

Some ABC commands are not supported.

Hi everyone,
I just found that some commands listed on the official ABC manual such as write_counter or sec are actually not supported by ABC.
The error message cmd error: unknown command keeps popping up whenever I input these commands.
The problem exists for both the ABC provided in this course or the version from the official github repository.
Is the manual wrong or did I downloaded the wrong version? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.