Skip to content

Commit

Permalink
vhdl: impl hir for cfg and discon spec for blks
Browse files Browse the repository at this point in the history
Support configuration and disconnection specifications in blocks. Also
ignore use clauses which are handled by the scoping pass earlier on.
This contributes towards issue #45.
  • Loading branch information
fabianschuiki committed Feb 9, 2018
1 parent 6daf0a9 commit a2e2959
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/vhdl/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ impl_codegen!(self, id: DeclInBlockRef, ctx: &mut llhd::Entity => {
DeclInBlockRef::Comp(id) => self.codegen(id, &mut ()),
DeclInBlockRef::Attr(_id) => Ok(()),
DeclInBlockRef::AttrSpec(_id) => Ok(()),
DeclInBlockRef::CfgSpec(_id) => Ok(()),
DeclInBlockRef::Discon(_id) => Ok(()),
}
});

Expand Down
3 changes: 3 additions & 0 deletions src/vhdl/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ impl<'sbc, 'sb, 'ast, 'ctx> DefsContext<'sbc, 'sb, 'ast, 'ctx> {
DeclInBlockRef::Comp(id) => self.declare_comp(id),
DeclInBlockRef::Attr(id) => self.declare_attr(id),
DeclInBlockRef::AttrSpec(_id) => (),
DeclInBlockRef::CfgSpec(_id) => (),
DeclInBlockRef::Discon(_id) => (),
}
}

Expand All @@ -174,6 +176,7 @@ impl<'sbc, 'sb, 'ast, 'ctx> DefsContext<'sbc, 'sb, 'ast, 'ctx> {
DeclInPkgRef::Comp(id) => self.declare_comp(id),
DeclInPkgRef::Attr(id) => self.declare_attr(id),
DeclInPkgRef::AttrSpec(_id) => (),
DeclInPkgRef::Discon(_id) => (),
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/vhdl/score/lower_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ impl<'sb, 'ast, 'ctx> ScoreContext<'sb, 'ast, 'ctx> {
}
}
}
ast::DeclItem::CfgSpec(ref decl) => {
let subid = CfgSpecRef(NodeId::alloc());
self.set_ast(subid, (scope_id, decl));
refs.push(subid.into());
}
ast::DeclItem::DisconDecl(ref decl) => {
let subid = DisconSpecRef(NodeId::alloc());
self.set_ast(subid, (scope_id, decl));
refs.push(subid.into());
}
ast::DeclItem::UseClause(..) => (),
ref wrong => {
self.emit(
DiagBuilder2::error(format!("a {} cannot appear in {}", wrong.desc(), container_name))
Expand Down
13 changes: 10 additions & 3 deletions src/vhdl/score/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ node_ref!(AliasDeclRef);
node_ref!(CompDeclRef);
node_ref!(AttrDeclRef);
node_ref!(AttrSpecRef);
node_ref!(CfgSpecRef);
node_ref!(DisconSpecRef);
node_ref!(ArrayTypeIndexRef);
node_ref!(GenericMapRef);
node_ref!(PortMapRef);
Expand Down Expand Up @@ -1206,7 +1208,7 @@ node_ref_group!(SubprogRef:
/// [x] component_declaration
/// [x] attribute_declaration
/// [x] attribute_specification
/// [ ] disconnection_specification
/// [x] disconnection_specification
/// [ ] use_clause
/// [ ] group_template_declaration
/// [ ] group_declaration
Expand All @@ -1226,6 +1228,7 @@ node_ref_group!(DeclInPkgRef:
Comp(CompDeclRef),
Attr(AttrDeclRef),
AttrSpec(AttrSpecRef),
Discon(DisconSpecRef),
);

/// All declarations that may possibly appear in a package body. See IEEE
Expand Down Expand Up @@ -1326,8 +1329,8 @@ node_ref_group!(DeclInSubprogRef:
/// [x] component_declaration
/// [x] attribute_declaration
/// [x] attribute_specification
/// [ ] configuration_specification
/// [ ] disconnection_specification
/// [x] configuration_specification
/// [x] disconnection_specification
/// [ ] use_clause
/// [ ] group_template_declaration
/// [ ] group_declaration
Expand All @@ -1349,6 +1352,8 @@ node_ref_group!(DeclInBlockRef:
Comp(CompDeclRef),
Attr(AttrDeclRef),
AttrSpec(AttrSpecRef),
CfgSpec(CfgSpecRef),
Discon(DisconSpecRef),
);

/// All declarations that may possibly appear in a process statement. See IEEE
Expand Down Expand Up @@ -1490,6 +1495,8 @@ node_storage!(AstTable<'ast>,
comp_decls: CompDeclRef => (ScopeRef, &'ast ast::CompDecl),
attr_decls: AttrDeclRef => (ScopeRef, &'ast ast::AttrDecl),
attr_specs: AttrSpecRef => (ScopeRef, &'ast ast::AttrDecl),
cfg_specs: CfgSpecRef => (ScopeRef, &'ast ast::CfgSpec),
discon_specs: DisconSpecRef => (ScopeRef, &'ast ast::DisconSpec),

exprs: ExprRef => (ScopeRef, &'ast ast::Expr),

Expand Down
11 changes: 11 additions & 0 deletions src/vhdl/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ impl_typeck!(self, id: DeclInPkgRef => {
DeclInPkgRef::Comp(id) => self.typeck(id),
DeclInPkgRef::Attr(id) => self.typeck(id),
DeclInPkgRef::AttrSpec(id) => self.typeck(id),
DeclInPkgRef::Discon(id) => self.typeck(id),
}
});

Expand Down Expand Up @@ -618,6 +619,8 @@ impl_typeck!(self, id: DeclInBlockRef => {
DeclInBlockRef::Comp(id) => self.typeck(id),
DeclInBlockRef::Attr(id) => self.typeck(id),
DeclInBlockRef::AttrSpec(id) => self.typeck(id),
DeclInBlockRef::CfgSpec(id) => self.typeck(id),
DeclInBlockRef::Discon(id) => self.typeck(id),
}
});

Expand Down Expand Up @@ -724,6 +727,14 @@ impl_typeck!(self, id: AttrSpecRef => {
unimp!(self, id)
});

impl_typeck!(self, id: CfgSpecRef => {
unimp!(self, id)
});

impl_typeck!(self, id: DisconSpecRef => {
unimp!(self, id)
});

impl_typeck!(self, id: BlockStmtRef => {
unimp!(self, id)
});
Expand Down
8 changes: 7 additions & 1 deletion tests/vhdl/decls_block.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ architecture bar of foo is
--constant const_a : BIT;

-- signal_declaration
--signal sig_a : BIT;
signal sig_a : BIT;

-- shared_variable_declaration
--shared variable shvar_a : BIT;
Expand All @@ -58,8 +58,14 @@ architecture bar of foo is
--attribute attr_a of NUM : type is '0';

-- configuration_specification
--for all : comp_a use entity foo;

-- disconnection_specification
--disconnect all : BIT after 0;

-- use_clause
use work.pkg.all;

-- group_template_declaration
-- group_declaration
begin end;
Expand Down

0 comments on commit a2e2959

Please sign in to comment.