File tree Expand file tree Collapse file tree 4 files changed +83
-4
lines changed
Expand file tree Collapse file tree 4 files changed +83
-4
lines changed Original file line number Diff line number Diff line change @@ -277,8 +277,9 @@ impl Conv<&IdentifierStatement> for ir::StatementBlock {
277277 ir:: Arguments :: Null
278278 } ;
279279
280- let symbol = symbol_table:: resolve ( value. expression_identifier . as_ref ( ) )
281- . map_err ( |_| ir_error ! ( token) ) ?;
280+ let resolved_path =
281+ context. resolve_path ( value. expression_identifier . as_ref ( ) . into ( ) ) ;
282+ let symbol = symbol_table:: resolve ( & resolved_path) . map_err ( |_| ir_error ! ( token) ) ?;
282283
283284 match & symbol. found . kind {
284285 SymbolKind :: SystemFunction ( _) => {
Original file line number Diff line number Diff line change @@ -1106,8 +1106,8 @@ pub fn eval_function_call(
11061106 ir:: Arguments :: Null
11071107 } ;
11081108
1109- let symbol = symbol_table :: resolve ( value. expression_identifier . as_ref ( ) )
1110- . map_err ( |_| ir_error ! ( token) ) ?;
1109+ let resolved_path = context . resolve_path ( value. expression_identifier . as_ref ( ) . into ( ) ) ;
1110+ let symbol = symbol_table :: resolve ( & resolved_path ) . map_err ( |_| ir_error ! ( token) ) ?;
11111111
11121112 match & symbol. found . kind {
11131113 SymbolKind :: SystemFunction ( _) => {
Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ impl Signature {
6666 }
6767 symbol. found
6868 }
69+ SymbolKind :: ProtoFunction ( _) => {
70+ let resolved = context. resolve_path ( path. clone ( ) ) ;
71+ let symbol = symbol_table:: resolve ( & resolved) . ok ( ) ?;
72+ match & symbol. found . kind {
73+ SymbolKind :: Function ( _) => symbol. found ,
74+ _ => return None ,
75+ }
76+ }
6977 SymbolKind :: ProtoAliasModule ( x) => {
7078 let symbol = symbol_table:: resolve ( & x. target ) . ok ( ) ?;
7179 return Some ( Signature :: new ( symbol. found . id ) ) ;
Original file line number Diff line number Diff line change @@ -1857,3 +1857,73 @@ fn concat() {
18571857"# ;
18581858 check_ir ( code, exp) ;
18591859}
1860+
1861+ #[ test]
1862+ fn proto_function ( ) {
1863+ let code = r#"
1864+ proto package Element {
1865+ type data;
1866+ function gt(a: input data, b: input data) -> logic;
1867+ }
1868+ package IntElement for Element {
1869+ type data = logic<8>;
1870+ function gt(a: input data, b: input data) -> logic {
1871+ return a >: b;
1872+ }
1873+ }
1874+ module ModuleA::<E: Element> (
1875+ a: input E::data,
1876+ b: input E::data,
1877+ r: output logic,
1878+ ) {
1879+ always_comb {
1880+ r = E::gt(a, b);
1881+ }
1882+ }
1883+ module Top (
1884+ a: input logic<8>,
1885+ b: input logic<8>,
1886+ r: output logic,
1887+ ) {
1888+ inst inner: ModuleA::<IntElement> (a, b, r);
1889+ }
1890+ "# ;
1891+ let exp = r#"module ModuleA {
1892+ input var0(a): unknown = 1'hx;
1893+ input var1(b): unknown = 1'hx;
1894+ output var2(r): logic = 1'hx;
1895+
1896+ comb {
1897+ var2 = unknown;
1898+ }
1899+ }
1900+ module Top {
1901+ input var0(a): logic<8> = 8'hxx;
1902+ input var1(b): logic<8> = 8'hxx;
1903+ output var2(r): logic = 1'hx;
1904+
1905+ inst inner (
1906+ var0 <- var0;
1907+ var1 <- var1;
1908+ var2 -> var2;
1909+ ) {
1910+ module ModuleA {
1911+ input var0(a): logic<8> = 8'hxx;
1912+ input var1(b): logic<8> = 8'hxx;
1913+ output var2(r): logic = 1'hx;
1914+ var var4(E.gt.return): logic = 1'hx;
1915+ input var5(E.gt.a): logic<8> = 8'hxx;
1916+ input var6(E.gt.b): logic<8> = 8'hxx;
1917+ func var3(E.gt) -> var4 {
1918+ var4 = (var5 >: var6);
1919+ }
1920+
1921+ comb {
1922+ var2 = var3(a: var0, b: var1);
1923+ }
1924+ }
1925+ }
1926+ }
1927+ "# ;
1928+ check_ir ( code, exp) ;
1929+ }
You can’t perform that action at this time.
0 commit comments