Trying to get ortree test working

This commit is contained in:
Greatorex 2022-02-21 17:59:41 +01:00
parent 296411da8c
commit 0a5a271409
7 changed files with 103 additions and 9 deletions

View File

@ -37,16 +37,14 @@ export deftype power (bool?! vdd, vss) { }
export template<pint N; pbool invert>
defproc ortree (bool? in[N]; bool out)
export template<pint N>
defproc ortree (bool? in[N]; bool! out; power supply)
{
bool tout;
{ N > 0 : "What?" };
pint i, end, j;
pbool isinv;
isinv = invert;
i = 0;
end = N-1;
@ -81,6 +79,12 @@ defproc ortree (bool? in[N]; bool out)
OR2_X1 C2Els[lenTree2Count];
OR3_X1 C3Els[lenTree3Count];
(h:lenTree2Count:C2Els[h].vdd = supply.vdd;)
(h:lenTree3Count:C3Els[h].vdd = supply.vdd;)
(h:lenTree2Count:C2Els[h].vss = supply.vss;)
(h:lenTree3Count:C3Els[h].vss = supply.vss;)
/* Reset the variables we just stole lol */
i = 0;
end = N-1;
@ -137,16 +141,14 @@ defproc ortree (bool? in[N]; bool out)
* Build a completion tree using a combination of 2-input and 3-input
* C-elements
*/
export template<pint N; pbool invert>
defproc ctree (bool? in[N]; bool out)
export template<pint N>
defproc ctree (bool? in[N]; bool! out; power supply)
{
bool tout;
{ N > 0 : "What?" };
pint i, end, j;
pbool isinv;
isinv = invert;
i = 0;
end = N-1;
@ -170,7 +172,6 @@ defproc ctree (bool? in[N]; bool out)
/*-- update range that has to be combined --*/
i = end+1;
end = end+j;
j = 0;
]
/* array that holds ALL the nodes in the completion tree */
@ -181,6 +182,12 @@ defproc ctree (bool? in[N]; bool out)
A_2C_B_X1 C2Els[lenTree2Count];
A_3C_B_X1 C3Els[lenTree3Count];
(h:lenTree2Count:C2Els[h].vdd = supply.vdd;)
(h:lenTree3Count:C3Els[h].vdd = supply.vdd;)
(h:lenTree2Count:C2Els[h].vss = supply.vss;)
(h:lenTree3Count:C3Els[h].vss = supply.vss;)
/* Reset the variables we just stole lol */
i = 0;
end = N-1;

View File

@ -122,3 +122,26 @@
(define assert-var-bool (lambda (x v) (assert-var-int x 1 v)))
(define set-bool-array
(lambda (ch width val)
(letrec ((ch)
(helper
(lambda (i v)
(cond
((=? i width) #t)
(#t (let ((tmp (string-append ch (string-append "[" (string-append (number->string i) "]")))))
(begin
(set tmp (% v 2))
(helper (+ 1 i) (truncate (/ v 2)))
)
))
)
)
))
(begin
(helper 0 val)
)
)
)
)

View File

@ -0,0 +1,2 @@
= "GND" "GND"
= "Vdd" "Vdd"

View File

@ -1,6 +1,8 @@
initialize
load-scm "helper.scm"
random
set GND 0
set Vdd 1
mode reset
cycle

View File

@ -0,0 +1,2 @@
= "GND" "GND"
= "Vdd" "Vdd"

View File

@ -0,0 +1,39 @@
/*************************************************************************
*
* This file is part of ACT dataflow neuro library.
* It's the testing facility for cell_lib_std.act
*
* Copyright (c) 2022 University of Groningen - Ole Richter
* Copyright (c) 2022 University of Groningen - Hugh Greatorex
* Copyright (c) 2022 University of Groningen - Michele Mastella
* Copyright (c) 2022 University of Groningen - Madison Cotteret
*
* This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later
*
* You may redistribute and modify this documentation and make products
* using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl).
* This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY
* AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2
* for applicable conditions.
*
* Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro
*
* As per CERN-OHL-W v2 section 4.1, should You produce hardware based on
* these sources, You must maintain the Source Location visible in its
* documentation.
*
**************************************************************************
*/
import "../../dataflow_neuro/treegates.act";
open tmpl::dataflow_neuro;
defproc ortree_15 (bool? in[15]; bool! out){
ortree<15> ortree_test(.in=in, .out=out);
ortree_test.supply.vss = GND;
ortree_test.supply.vdd = Vdd;
}

View File

@ -0,0 +1,19 @@
set-bool-array "t.in" 15 0
cycle
mode run
assert t.out 0
set-bool-array "t.in" 15 1
cycle
assert t.out 1
set-bool-array "t.in" 15 0
cycle
assert t.out 0
set-bool-array "t.in" 15 15
cycle
assert t.out 1